Quality RTOS & Embedded Software

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




Loading

vTaskDelayUntil suspend all the tasks

Posted by Nobody/Anonymous on April 17, 2007
Why does it suspend all tasks and then resume them?
Isn't it possible wait a fixed period without suspend the tasks?

I created 2 tasks that switch on\off leds. Each task has its own leds. In one task I repalce the vTaskDelayUntil with for cycles simulated a waiting period.
To be sure under the for (always) { } I added a CRITICAL REGION.
-----------------------
static portTASK_FUNCTION( vLEDFlashTask1, pvParameters )
{
portTickType xFlashRate, xLastFlashTime;
unsigned portBASE_TYPE uxLED;

int i;
int max;
max=0x7FFFFFF;

/* The parameters are not used. */
( void ) pvParameters;

uxLED=1;

xFlashRate = ledFLASH_RATE_BASE + ( ledFLASH_RATE_BASE * ( portTickType ) uxLED );
xFlashRate /= portTICK_RATE_MS;

/* We will turn the LED on and off again in the delay period, so each
delay is only half the total period. */
xFlashRate /= ( portTickType ) 1 ;

/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastFlashTime = xTaskGetTickCount();

for(;;)
{
taskENTER_CRITICAL();
{
/* Delay for half the flash period then turn the LED on. */
vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED-1 );

/* Delay for half the flash period then turn the LED off. */
//vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED-1 );

/* Delay for half the flash period then turn the LED on. */
//vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED );

/* Delay for half the flash period then turn the LED off. */
//vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED );
}
taskEXIT_CRITICAL();
}
}
------------------------
When I run, leds of this task are always lighting fast. It not waits as the for always cycle says. Why?

RE: vTaskDelayUntil suspend all the tasks

Posted by Richard on April 17, 2007
I'm not sure why you have the critical sections, but if you have both tasks structured like this then you are going to spend nearly all the time with interrupts disabled, which is probably your problem.

Take a look at FreeRTOS\Demo\Common\Minimal\flash.c which contains simple LED flash tasks using vTaskDelayUntil().

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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