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] [February 2008 Threads] vTaskDelayUntil doesn't wait ?Posted by Martin Cibulski on February 8, 2008 Hello,
I'm programming a motor controller in a task. To have a constant schedule for my controller I use the vTaskDelayUntil function. But I found that my controller worked much too fast.
So I wrote some test code into my task to find out how long vTaskDelayUntil actually waits. (I don't show all code to keep my posting small) - - - - -
#define MOT_TASK_PERIOD((portTickType)100) . . . portTASK_FUNCTION (task_mot, pParameters __attribute__ ((unused))) { staticportTickTypexLastWakeTime = 500;
intnMot; MOTOR*pMot; intnSpeedStep; intnTick1, nTick2;
DEBUG_LINE ("task_mot(.)"); i2c_init (MOT_I2C_BUS_NO, MOT_I2C_KHZ); mot_init ();
while (1) { nTick1 = xTaskGetTickCount(); vTaskDelayUntil (&xLastWakeTime, MOT_TASK_PERIOD); nTick2 = xTaskGetTickCount(); . . . - - - - -
When I debug the task and stop behind these statements, the variables have the following values: nTick1 3 (OK, only 3 milliseconds since system start) xLastWakeTime 600 (which is 500 + MOT_TASK_PERIOD) nTick2 3 (should be at least 600)
Why is nTick2 not 600 or more ? vTaskDelayUntil should wait until 600 Ticks have been counted, right ?
I use FreeRTOS 4.7.1 on an LPC2148 with GCC. The same happened with an earlier release (4.5 ?).
What did I do wrong here ?
Thanks for help, Martin
RE: vTaskDelayUntil doesn't wait ?Posted by woops_ on February 9, 2008 You initialized xLastWakeTime to an arbitrary value and this probably makes the scheduler think the actual time has overflowed since vTaskDelayUntil was called. You can step into vTaskDelayUntil to check this. Try initializing the xLastWakeTime to the actual time as shown in the API doc example. If this does not fix your problem check the tick is actually running.
RE: vTaskDelayUntil doesn't wait ?Posted by Martin Cibulski on February 9, 2008 Yes, initializing the xLastWakeTime to the actual time solved my problem. Now my task runs every 100 ms as exspected.
Thank you, Martin
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|