trigger timer before periode expiration

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

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

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

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

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

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

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

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

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.