Quality RTOS & Embedded Software

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




Loading

trigger timer before periode expiration

Posted by po220 on November 11, 2016

Hi

I'm using a periodic timer

Timer1 = xTimerCreate("Timer1", 10000, pdTRUE, (void *)0, Timer1Callback) ; xTimerStart(Timer1, 0) ;

How can I force the timer to expire immediately ?

15:10 pm => Timer1 start 15:20 pm => Timer1 should execute the callback function

and me, at 15;12 pm, I need to execute the callback function, with(top solution) or whithout reset of the timer.

I do not see any solution here http://www.freertos.org/FreeRTOS-Software-Timer-API-Functions.html

Thanks in advance


trigger timer before periode expiration

Posted by rtel on November 11, 2016

If you don't want to reset the timer, just call the timer callback function as any other function. Otherwise you would have to stop the timer then restart it with a new timeout time (or just change its period so it expires at the new desired time, which effectively does the same thing).


trigger timer before periode expiration

Posted by po220 on November 11, 2016

Thank for your answer

What happens by calling the callback directly? Timer1Callback(Timer1) ;

The timer don't restarts for a complete new period.

No risk of disrupting timer normal operation ? or I need make a xTimerReset( Timer1,0); just before the Timer1Callback(Timer1) ?

thanks


trigger timer before periode expiration

Posted by rtel on November 11, 2016

Timer callback functions are just standard C functions, and can be called by another task (in which case the function runs in the context of the calling task). As all you are doing is calling a C function it will not change the software timer, which will continue and expire just as it would have done otherwise.


trigger timer before periode expiration

Posted by po220 on November 11, 2016

Ok

xTimerReset( Timer1,0); Timer1Callback(Timer1) ;

Is therefore a good solution ? How to prevent the callback function from calling 2 times ? Semaphore ?

Thanks


trigger timer before periode expiration

Posted by davedoors on November 11, 2016

Im confused. What are you trying to do?

15:10 pm => Timer1 start 15:20 pm => Timer1 should execute the callback function and me, at 15;12 pm, I need to execute the callback function, with(top solution) or whithout reset of the timer.

So you thought the timer should expire at 15:20, but something happened that means it now needs to expire at 15:12. Do you want it to execute at 15:20 as well? If so just call the callback function at 15:12 from a task. If you dont want it to execute at 15:20 as well just stop the time then call the callback from a atsk.


trigger timer before periode expiration

Posted by po220 on November 11, 2016

I need

15:10 => timer execute callback function 15:12 => execute callback function "manualy" 15:22 =>timer execute callback function 15:32 =>timer execute callback function ....


trigger timer before periode expiration

Posted by po220 on November 11, 2016

My solution, if you confirm.

~~~ xTimerReset(Timer1,0);

while(xTaskGetHandle("Tache1") != NULL) vTaskDelay(10) ; //Wait for callback function end.

Timer1Callback(Timer1) ; ~~~

the callback fonction create the "Tache1" task.

It's OK for you ?

Thanks


trigger timer before periode expiration

Posted by rtel on November 11, 2016

You could perform the reset of the timer from the timer callback function itself. That way if you manually execute the callback function the timer will automatically reset at that point.


[ 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