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

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) 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