dkilshtein10 wrote on Tuesday, September 07, 2010:
I use FreeRTOS V6.0.5 on ARM1176JZF-S
I created two small tasks to test freeRtos:
1st task - toggle LEDs using the vTaskDelayUntil function
2nd task - just toggle LEDs
//the prototypes
static portTASK_FUNCTION_PROTO( vLEDFlashTask2, pvParameters );
static portTASK_FUNCTION_PROTO( vLEDFlashTask1, pvParameters );
void vStartLEDFlashTasks( unsigned portBASE_TYPE uxPriority )
{
xTaskCreate( vLEDFlashTask1, “LED1”, configMINIMAL_STACK_SIZE, ( void * ) NULL, uxPriority, ( xTaskHandle * ) NULL );
xTaskCreate( vLEDFlashTask2, “LED2”, configMINIMAL_STACK_SIZE, ( void * ) NULL, uxPriority, ( xTaskHandle * ) NULL );
}
//task 1
portTickType xLastWakeTime1;
static portTASK_FUNCTION( vLEDFlashTask1, pvParameters )
{
xLastWakeTime1 = xTaskGetTickCount ();
for( ;; )
{
vTaskDelayUntil( &xLastWakeTime1, 1000 );
vParTestSetLED(1, 1);
vTaskDelayUntil( &xLastWakeTime1, 3000 );
vParTestSetLED(1, 0);
}
}
//task 2
static portTASK_FUNCTION( vLEDFlashTask2, pvParameters )
{
for( ;; )
{
vParTestSetLED(0, 0);
taskYIELD();
}
}
These tasks work fine (LED1 toggles with 1000, 3000 and LED 0 toggles all the time)
The problem occurs when i did the following:
I changed the vLEDFlashTask2 to use vTaskDelayUntil (same as the vLEDFlashTask1 task)
Now it looks like:
portTickType xLastWakeTime2;
static portTASK_FUNCTION( vLEDFlashTask2, pvParameters )
{
xLastWakeTime2 = xTaskGetTickCount ();
for( ;; )
{
vTaskDelayUntil( &xLastWakeTime2, 500 );
vParTestSetLED(0, 1);
vTaskDelayUntil( &xLastWakeTime2, 250 );
vParTestSetLED(0, 0);
}
}
The problem is, when I run the first vTaskDelayUntil (no matter on which task) I get “stuck” inside the idle task forever and nothing else happens.
The tick timer works fine.