Quality RTOS & Embedded Software

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


Loading

vTaskDelay is to short

Posted by Patrick_ECR on December 9, 2011
Hello

I'm new on FreeRTOS and started with a own simple project to test mukltitasking.

Now i've got the first problem. In the code below i call vTaskDelay to wait 500ms before toggeling the output. But when I measure the frequency with scope, I can see, that the delay is arround 50us. It doesn't matter which time is entered, I always get the same delay. Any suggestions?

static portTASK_FUNCTION(vMainTask2, pvParameters) {
const portTickType xDelay = 500/portTICK_RATE_MS;
for(;;){
vTaskDelay(xDelay);
Bit3_NegVal();
}
}



The timertick works correct at 1ms. I've already changed the settings of portTICK_RATE_MS and it's parameters to the right value.

I'm using the MCF52259 from Freescale, IDE: codewarrior 10.1 (Eclips version), FreeRTOS V7.0.2

Thanks for help!


Best regards
Patrick

RE: vTaskDelay is to short

Posted by Richard on December 9, 2011
“The timertick works correct at 1ms. I've already changed the settings of portTICK_RATE_MS and it's parameters to the right value.”


That is not a user configurable value, please set it back to its default as it should be calculated automatically from the value of configTICK_RATE_HZ. Only the values in FreeRTOSConfig.h are user configurable. Note that portTICK_RATE_MS is only useful when configTICK_RATE_HZ is equal to or less than 1000.

Regards.

RE: vTaskDelay is to short

Posted by Patrick_ECR on December 9, 2011
Thats right. I just wanted to say that i've configured configTICK_RATE_HZ in FreeRTOSConfig.h.
portmacro.h is at default-state.

Do you know this problem or any reason for that?

RE: vTaskDelay is to short

Posted by Richard on December 9, 2011
Please take a copy of the tick count both before and after the delay call as:

ulTimeBefore = xTaskGetTickCount();
vTaskDelay(xDelay);
ulTimeAfter = xTaskGetTickCount();

and then see what (ulTimeAfter - ulTimeBefore) is.

Regards.

RE: vTaskDelay is to short

Posted by Patrick_ECR on December 12, 2011
The difference is always zero/one. So there is no delay by calling the vTaskDelay().

I also tried to call the function with different xDelay's and watched the pin with scope. But there is no difference neither with 5 nor with 500. Togglefrequency of the pin is somewhere above 10kHz.

RE: vTaskDelay is to short

Posted by Dave on December 12, 2011
If an interrupt vector is used to yield a task (a yield is done inside vTaskDelay()), have you installed the interrupt handler correctly in the vector table? Maybe the handler is just using a default handler that does nothing but return right away. Have you tried stepping through the vTaskDelay() function to see what happens? It is not a long function.

RE: vTaskDelay is to short

Posted by Patrick_ECR on December 12, 2011
Yes i already debugged the vTaskDelay but didn't see anything unuasual (except it doesn't wait :) ).

I use the internal PIT0 (programable interrupt timer) to generate the 1ms tick. This one i checked with the function vApplicationTickHook which works well.

So i'm confused that i have to configure a second int-vector?

Is it right that during PIT-int an new interrupt is set to change task after PIT-Int? Which function should be called with the second interrupt?

Thank you for helping me!

RE: vTaskDelay is to short

Posted by Richard on December 12, 2011
Please read the "Resources Used by the Kernel" section on one of the ColdFire V2 documentation pages, for example:
http://www.freertos.org/Free-RTOS-for-ColdFire-MCF5222x-using-CodeWarrior.html

Regards.

RE: vTaskDelay is to short

Posted by Patrick_ECR on December 14, 2011
I've got the problem.

To make the vTaskDelay work, I had to initiaize and enable another (software)interrupt which calls the vPortYieldISR. Without this it doesn't work.

Thank to everybody of you for help!


[ 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