Problems with vDelayTask (FreeRTOS.org)

Oct 02, 2007 8 Replies

I am developing an embedded application using the FreeRTOS.org operating system and I already could get through the basics.



My problem now is in the use of two very important functions and theoretically easy to use: vDelayTask() vDelayTaskUntil()



As soon as it blocks the task for the first time, it seems that it never unblocks again. Maybe it is a problem with the scheduler? I have not altered the main files, just my own tasks.



The target is a MSP430. Any clue? Thanks



= vTaskDelay() and vTaskDelayUntil().

Of coarse, what else could it possibly be? [yes, that is sarcasm, its an English thing]

Not without more information.

A working demo is provided for each port to provide you with a preconfigured environment that demonstrates many of the kernel features. Did the demo work for you without modification (assuming similar hardware is being used)? Did you base your project on the preconfigured example for the port you are using - or create it from scratch yourself?

Can you post the code for your task?

Regards, Richard. + http://www.FreeRTOS.org 13 official architecture ports, 1000 downloads per week. + http://www.SafeRTOS.com Certified by TÜV as meeting the requirements for safety related systems.

Also - are you sure the tick interrupt is running. If not, then your task will never unblock.

Regards, Richard. + http://www.FreeRTOS.org 13 official architecture ports, 1000 downloads per week. + http://www.SafeRTOS.com Certified by TÜV as meeting the requirements for safety related systems.

More precisely:

If I run only this task and the idle task, after vDelayTask is called the system will loop forever in the idle task

re

for

Hi Richard, thanks for your answer.

I based the code in the flash.c application. But to be honest, I have not tested this task as originally distributed, because my board doesn't have any leds. So what I did before developing the full program was adapting the comtest.c inside flash.c, so that I could periodically see something through hyperterminal.

The code is:

static void vTestTimerTask( void *pvParameters ) { ( void ) pvParameters; unsigned char cByteToSend =3D 'a'; portTickType xFlashRate, xLastFlashTime; xFlashRate =3D 1000;

xLastFlashTime =3D xTaskGetTickCount();

for(;;){ /* function put_uart sends a byte through the serial port...it's been tested and works fine */ put_uart (cByteToSend); // Wait for the next cycle.- Copied from

formatting link
elayuntil.html vTaskDelayUntil( &xLastFlashTime, xFlashRate ); /* After vTaskDelayUntil the execution never comes back here */ cByteToSend++; } }

Does put_uart() make any blocking calls? Maybe it is getting blocked there. Other than that, there does not appear to be anything amiss here.

Can you confirm that the tick interrupt is running?

One way of doing this is to provide the following function - you can write it in main.c.

unsigned long ul = 0;

void vApplicationTickHook( void ) { ____ul++; }

then set configUSE_TICK_HOOK to 1 in FreeRTOSConfig.h. You should see that ul gets incremented on each tick interrupt. Alternatively, toggle a pin from within vApplicationTickHook() and look at it on a scope to ensure the frequecy of the tick interrupt is as expected.

Another thing you could do is use an idle hook to call xTaskGetTickCount(), and ensure that the tick count value is incrementing at the expected rate. The idle hook has the following form:

void vApplicationIdleHook( void ) { portTickType x;

____x = xTaskGetTickCount(); }

This time you would need to set configUSE_IDLE_HOOK to 1 instead.

Regards, Richard. + http://www.FreeRTOS.org 13 official architecture ports, 1000 downloads per week. + http://www.SafeRTOS.com Certified by TÜV as meeting the requirements for safety related systems.

re.

at

),

No, put_uart does not make any blocking call. But to be sure, I commented the line and so the task is only a matter of incrementing a variable.

But the problem is still there. And you got it, the tick interrupt is not running. The program never goes to the vApplicationTickHook() neither x increments in the second case. What should I do to fix it?

Precisely: I'm using the MSP430 IAR port.

Thanks again!

I am not too familiar with the MSP430/IAR port as it was produced by a third party

formatting link
It might be that the timer configuration is for a different MSP430 device.

The timer configuration will be in a function prvSetupTimerInterrupt() within port.c. Take a look at this code to ensure it is correct for your MSP430 variant - and that the interrupt is configured correctly.

Regards, Richard.

  • formatting link
13 official architecture ports, 1000 downloads per week.

  • formatting link
    Certified by TÜV as meeting the requirements for safety related systems.

ird

mer

I'll check the hardware. Thanks again for all the help. Have a nice day!

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required