FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2009 Threads] task timing issue with freertos on 9s08Posted by Lav Thyagarajan on 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");
}
RE: task timing issue with freertos on 9s08Posted by Dave on November 20, 2009 There is no official 9S08 port so people are not going to be able to help you with the port itself, which may not be working correctly. If you can repost your code with a tab in front of every line then the forum will display it in a readable way and you may get some suggestions about the task implementation.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|