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

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