1 year, 8 months ago.

Pausing the Timer, Timeout, Ticker using mbed?

How to do this not using HAL. Why there are only read, start, stop function? Where are pause and resume?

1 Answer

1 year, 8 months ago.

You can pause a Timer by using stop and start. It only returns to zero if you call reset.

If I have a ticker running to do something every second why pause it for some unknown length of time and then restart it with an unknown amount of time left until it next triggers? Doesn't it make more sense to simply stop it and then restart it, that way I know exactly when it's next going to trigger. Tickers and timeouts aren't stopwatches, they are for scheduling future events, if you want to change the time that something is scheduled for then most of the time it makes more sense to cancel it and schedule a new event for the new time.

I am using Timeout. Timeout calls for function which terminate some thread. I need to pause it. Pausing called by button. Button may be pressed for unknown times. I can't read from Timeout, how much time is left. I can't pause it either. All I can is to call Kernel::get_ms_count() and take this new time for Timeout. And this is bad, cause i need for double-triple checking for get_ms_count() as my program runs many threads. I could pause Timeout for stm32 HAL, but i don't know which stm32 timer is using for Timeout.

posted by Alexander Malakhov 07 Jan 2019

Start a timer at the same time as the timeout. Stop the timer and cancel the timeout when the button is pressed. When the button is released check the timer, schedule the timeout and then restart the timer.

posted by Andy A 07 Jan 2019