FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2007 Threads] vTaskDelayUntil suspend all the tasksPosted 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 tasksPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|