lthyagarajan wrote on Tuesday, November 17, 2009:
Hello, I have just started using freertos on a 9S08(GT60) using CW 6.2.
This is what I have:
3 tasks + 1 idle task.
Task1 : blocks for 100 ms using Vdelayuntil(). priority( idle+1)
Taks2: blocks for 50 ms using Vdelayuntil(). priority(idle+2)
Task3: blocks for a binary semaphore. priority(idle+3)
The semaphore is given by an interrupt generated by ( tim1 channel 1) every 100 ms. The interrupt rate is 10ms, and the TICKS_TO_WAIT is set to 10.
The RTOS tick is set at 1ms using tim1 channel 0 .
The problem:
When I have all three tasks running, the tasks are NOT running at their specified repeat rates. ( its all over the place).I am toggling an output pin in each of the tasks to determine the timing.
If I remove task2, then task1 and task3 run at the specified repeat rates.
Will appreciate any help/hints to this problem.
Thanks!!
Lav
// ----------------------------//
code snippets below
//----------------------//
*******************************************************************************
*
*
*
*******************************************************************************
*/
static void vTaskone( void *pvParameters )
{
// pvParameters = pvParameters;
portTickType xLastWakeTime;
const portTickType xFrequency = 100;
// Initialise the xLastWakeTime variable with the current time.
xLastWakeTime = xTaskGetTickCount();
for( ;; )
{
//#if !defined(_FCS_)
// Wait for the next cycle.
vTaskDelayUntil( &xLastWakeTime, xFrequency );
PTDD_PTDD4 = ~PTDD_PTDD4;
//#endif
// vTaskDelay(500);
}
}
/*
*******************************************************************************
*
*
*
*******************************************************************************
*/
void vTaskTwo ( void *pvParameters )
{
// pvParameters = pvParameters;
portTickType xLastWakeTime;
const portTickType xFrequency = 50;
// Initialise the xLastWakeTime variable with the current time.
xLastWakeTime = xTaskGetTickCount();
for (;:smileywink:
{
//#if !defined(_FCS_)
vTaskDelayUntil( &xLastWakeTime, xFrequency );
//PTDD_PTDD3 = ~PTDD_PTDD3;
//#endif
// vTaskDelay(250);
}
}
*******************************************************************************
*
*
*
*******************************************************************************
*/
void vTaskThree ( void *pvParameters )
{
// pvParameters = pvParameters;
/* We are using the semaphore for synchronisation so we create a binary
semaphore rather than a mutex. We must make sure that the interrupt
does not attempt to use the semaphore before it is created! */
vSemaphoreCreateBinary(tsk3_semphr);
for (;:smileywink:
{
/* We want this task to run every 30 ticks of a 10 ms timer. The semaphore
was created before this task was started.
Block waiting for the semaphore to become available. */
if( xSemaphoreTake( tsk3_semphr, LONG_TIME ) == pdTRUE )
{
PTDD_PTDD3 = ~PTDD_PTDD3;
}
}
}
*******************************************************************************
*
*
*
*******************************************************************************
*/
if (xTaskCreate( vTaskone, (const signed char *)“MyTaskone”, configMINIMAL_STACK_SIZE , NULL, ( tskIDLE_PRIORITY + 1 ), NULL ) == pdFAIL)
{
for (;:smileywink: __asm (“nop”);
}
if (xTaskCreate( vTaskTwo, (const signed char *)“MyTaskTwo”, configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 2 ), NULL ) == pdFAIL)
{
for (;:smileywink: __asm (“nop”);
}
if (xTaskCreate( vTaskThree, (const signed char *)“MyTaskThree”, configMINIMAL_STACK_SIZE, NULL, ( tskIDLE_PRIORITY + 3 ), NULL ) == pdFAIL)
{
for (;:smileywink: __asm (“nop”);
}