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


using vTaskDelayUntil questions

Posted by Brian Carver on November 4, 2009
I am trying a simple delay into my simple program so I can control the rate of delay to flash an LED on/off. Here is the code:

int i;
portTickType xLastWakeTime;
const portTickType xFrequency = 10000;

LATBbits.LATB2 = 1;// Set LAT register to turn on LED
xLastWakeTime = xTaskGetTickCount();

vTaskDelayUntil(&xLastWakeTime, xFrequency);
//for(i=0; i<0xFFFF; i++);
//for(i=0; i<0xFFFF; i++);
//for(i=0; i<0xFFFF; i++);

LATBbits.LATB3 = ~LATBbits.LATB3;// Set LAT register bit 3 to turn on LED

When I use the function vTaskDelayUntil the code does not work, but If I comment out my busy wait loops, those work well. I know the delayUntil function is a better way to go, as the processor might go to sleep in the idle task (hopefully a correct assumption)

I followed the debugger into the code, I can see the task get placed into the wait queue, but it's really hard to see when the task is released from the wait queue.

Any suggestion?

RE: using vTaskDelayUntil questions

Posted by MEdwards on November 4, 2009
Check the tick interrupt is running. If not then the task will never leave the delay.

10000 is potentially a long delay too, 10 seconds if the tick frequency is 1KHz, 100 seconds if the tick frequency is 100Hz.

RE: using vTaskDelayUntil questions

Posted by Brian Carver on November 4, 2009
You are correct, the tick interrupt is not running. I changed my code to this:
xLastWakeTime = xTaskGetTickCount();
vTaskDelayUntil(&xLastWakeTime, xFrequency);

I set a debug break on the vTaskDelayUntil line to read the value xLastWakeTime. The value read zero every time, i looped through the application.

Thinking I had the right option I turned on

#define configUSE_TICK_HOOK1

That resulted into a compile error:
Source\tasks.c:1362: undefined reference to `vApplicationTickHook'

I am using a PIC24F16KA102 for my chip. So I know the scheduler is started as I call vTaskStartScheduler(); and that starts the task interrupt.

The suggestion was spot on, but I really don't know how to make sure the tick interrupt is really working.

RE: using vTaskDelayUntil questions

Posted by Brian Carver on November 5, 2009
I really now know that the scheduler is giving control to my function but the interrupt tick is not working. I added an extra task to send a character on the UART. The uartTask and my ledTask (flasher) does not work together. At least I am not seeing a context switch between the two. So I have a configuration issue with my code, any more suggestions?

[ 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