amarjith wrote on Tuesday, September 10, 2013:
I am beginner in RTOS here i tried to execute four tasks simultaneously(with same priority). But the program execution is only in Task4 and never exit the loop.Using pic24fj256ga106 and FreeRTOS7.5.3 , I set break point in task4 as shown below when execution reaches at break point the values are a=0,b=0,c=0,d=0 and xTickCount =0. if i run one time it again reach the break point and values would be a=0,b=0,c=0,d=1 and xTickCount =94, 2nd time a=0,b=0,c=0,d=2 and xTickCount =188 and so on , it never exit task4. Please help me what could be the reason how can i run all simultaneously. please…
unsigned int a=0,b=0,c=0,d=0;
int main( void )
{
prvSetupHardware();
xTaskCreate( vTask1, “Task 1”, 200, NULL, 1, NULL );
xTaskCreate( vTask2, “Task 2”, 200, NULL, 1, NULL );
xTaskCreate( vTask3, “Task 2”, 200, NULL, 1, NULL );
xTaskCreate( vTask4, “Task 2”, 200, NULL, 1, NULL );
vTaskStartScheduler();
/* If all is well then main() will never reach here as the scheduler will
now be running the tasks. If main() does reach here then it is likely that
there was insufficient heap memory available for the idle task to be created.
CHAPTER 5 provides more information on memory management. */
for( ;; );
}
void vTask1( void *pvParameters )
{
volatile unsigned long ul;
for( ;; )
{
PORTF = 0x0004;
a++;
}
}
void vTask2( void *pvParameters )
{
volatile unsigned long ul;
for( ;; )
{
PORTF = 0x0008;
b++;
}
}
void vTask3( void *pvParameters )
{
volatile unsigned long ul;
for( ;; )
{
PORTF = 0x0008;
c++;
}
}
void vTask4( void *pvParameters )
{
volatile unsigned long ul;
for( ;; )
{
PORTF = 0x0008; // set break point here
d++;
for( ul = 0; ul < 50000; ul++ )
{
;
}
PORTF = 0x0004;
for( ul = 0; ul < 50000; ul++ )
{
;
}
}
}