Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner