Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

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


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists