first project usig FreeRTOS with PIC32MX

chaabanemalki wrote on Wednesday, January 29, 2014:

Hello,

I really need some help here, with my first attemp to blink a LED
inside a simple task,

I’m using pic32MX795F512L, and I checked the configuration fuses
without FreeRTOS kernel, everything works fine.

then i used the demo provided with the FreeRTOS download to make my own
code, here is the small code that i create

#define LEDR_SYSTEM LATCbits.LATC1 // inverse

static void prvSetupHardware( void );
portBASE_TYPE TaskValid ;

void vTask1(void *pvParameters)
{

     portTickType xLastWakeTime;
     char toggle;
     xLastWakeTime = xTaskGetTickCount();

     for(;;)
     {
             if(toggle ==1)

LEDR_SYSTEM = 0, toggle = 0;
else
LEDR_SYSTEM = 1, toggle = 1;

vTaskDelayUntil(&xLastWakeTime,(10000/portTICK_RATE_MS));
}

}

void main( void )
{

TRISCbits.TRISC1 = 0;

     TaskValid = xTaskCreate(vTask1,"Task 1",1000,NULL,1,NULL);


     vTaskStartScheduler();


     for(;;);

}

So I had a clean build for this code and ofcourse nothing working on the
board, yet i noticed when i start debugging that the debugger tells me
that the breakpoint in the line “portTickType xLastWakeTime;” in the
task function is not valid, here is the exact error i’m getting

Break point at line 82 in file C:/*****/main.c cannot be resolved to a
valid program memory address

and i’m getting the same error in each line inside the vTask1 function

I think that the function xTask1 function doesn’t exist in the program
memory, and some how the code failed to create it.

I checked the return value of the xTaskCreate and it is equal to 1,
which means that the task was created successfully

another thing that i noticed is about the parameters portTICK_RATE_MS,
i followed it’s definition and here what i found

#define portTICK_RATE_MS ( ( portTickType ) 1000 /
configTICK_RATE_HZ )

#define configTICK_RATE_HZ ( ( portTickType ) 1000 )

That’s mean portTICK_RATE_MS is equal to 1 ?, is that normal ? cause i’m
not sure yet whether the portTICK_RATE_MS is defined and calculated by
default or it is the programmer job.

I Really appreciate any help from you guys, cause i have like 10 days to
integrate a GPS module in FreeRTOS

rtel wrote on Wednesday, January 29, 2014:

configTICK_RATE_MS is the tick rate, in ms. Therefore, if your tick frequency is 1000, then there is one tick every ms to make the 1000 ticks in a second, so 1 is the expected value. The latest FreeRTOS version in SVN has renamed the constant configTICK_PERIOD_MS (with backward compatibility maintained so configTICK_RATE_MS is #defined to configTICK_PERIOD_MS so both work).

Did you start your project by adapting the existing MPLAB X project found in the FreeRTOS download? There is a build configuration for the pic32MX795, the following page shows how to select it - http://www.freertos.org/port_PIC32_MIPS_MK4.html

I would suggest starting with that, with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 1, that will give you a very simple two task example that is configured correctly for your part.

Once you have that building and running you can replace the two tasks with your own task, and take it from there.

Regards.