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

Problems with xTaskDelay()

Posted by Nobody/Anonymous on March 1, 2007
Hello,

I've some mysterious problems with the xTaskDelay function. I start a task an everything runs until the xTaskDelay()-function is called and never returns.
But if I create a "do-only-i++"-task with a priority set to tskIDLE_PRIORITY+1 and set the other task to tskIDLE_PRIORITY+2, everything runs normal.

I don't know, that isn't the way it should work, is it?
By the way, I use a LPC2106 Board, GCC4.1.1 and FreeRTOS V3.2.3.

So, if someone have a good guess, what might be wrong, all answers are welcome.
Thanks.

RE: Problems with xTaskDelay()

Posted by Nobody/Anonymous on March 1, 2007
I don't understand your explanation. Can you try rewording or giving an example simple bit of code.

If xTaskDelay() does not return are you sure the tick interrupt is running correctly?

Are you using an idle hook that calls a blocking function?

RE: Problems with xTaskDelay()

Posted by Nobody/Anonymous on March 1, 2007
I hope this time it is more understandable:

I create a task:
-> xTaskCreate(v_task_Heartbeat,(const signed portCHAR * const) "heartbeat", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &x_task_Heartbeat_Handle);
which should do:
->void v_task_Heartbeat(void *pvParameters)
{
pvParameters = 0;

HEARTBEAT_LED_PORT = HEARTBEAT_LED;// set to output
// endless loop
for(;;)
{
vTaskDelay(HEARTBEAT_LED_DELAY);// wait for 500 ticks (0.5s)
HEARTBEAT_LED_PORT_CLR = HEARTBEAT_LED; // turn on LED
vTaskDelay(HEARTBEAT_LED_DELAY);// wait for 500 ticks (0.5s)
HEARTBEAT_LED_PORT_SET = HEARTBEAT_LED; // turn off LED
}
}

I use openocd to debug the program and when i reach the line: vTaskDelay(....), the programm jumps into the function. My task get delayed, but never wake up. When i step further the programm calls the Idle-Task an check if there are other task ready to run. Then i let the programm continue and after a short time i hold it. The programm now has reached an abort-error-loop.
Now i increase the Task-Priority to 2 and create a new task:
->void v_task_idle_2(void *pvParameters)
{
pvParameters = 0;
u32 i;

// endless loop
for(;;)
{
i++;
}
}
with a Priotity of tskIDLE_PRIRITY+1. If i run this programm, everything seems to run normal an my LED is blinking.
I don't use an idle hook.

Some more settings:
->
#define configUSE_PREEMPTION1
#define configUSE_IDLE_HOOK0
#define configCPU_CLOCK_HZ( ( unsigned portLONG ) 58982400 )/* =12Mhz xtal multiplied by 4 using the PLL. */
#define configTICK_RATE_HZ( ( portTickType ) 1000 )
#define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 8 )
#define configMINIMAL_STACK_SIZE( ( unsigned portSHORT ) 150 )
#define configTOTAL_HEAP_SIZE( ( size_t ) ( 10 * 1024 ) )
#define configMAX_TASK_NAME_LEN( 16 )
#define configUSE_TRACE_FACILITY0
#define configUSE_16_BIT_TICKS0
#define configIDLE_SHOULD_YIELD1


/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

#define INCLUDE_vTaskPrioritySet1
#define INCLUDE_uxTaskPriorityGet1
#define INCLUDE_vTaskDelete0
#define INCLUDE_vTaskCleanUpResources0
#define INCLUDE_vTaskSuspend1
#define INCLUDE_vTaskDelayUntil1
#define INCLUDE_vTaskDelay1


RE: Problems with xTaskDelay()

Posted by Nobody/Anonymous on March 1, 2007
By creating a second idle task that never blocks, you are soaking up all the available CPU so prvIdleTask is never executed. That seems to make it work. So I would then guess that the problem lies in prvIdleTask.

But in your configuration the prvIdleTask in tasks.c will do nothing at all if you create no tasks at tskIDLE_PRIORITY - are you sure you don't have such tasks also defined?

It all sounds like either an interrupt going astray or perhaps your SWI handler not being setup properly and thus you're getting aborts when trying to execute garbage?

Robin

RE: Problems with xTaskDelay()

Posted by Nobody/Anonymous on March 1, 2007
Hello Robin,
thanks for your answer. I checked the tasks.c, the interrupt routines and a few other functions, and there was nothing. While searching the code, i found a bug in my own code. (Actually i searched my own code a few times but didn't saw it before). Now everything seems to work fine. (until the next bug :-) )

Again, thanks to all for helping me out.


[ 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