cancel
Showing results for 
Search instead for 
Did you mean: 

Timer implementation

Bs.1
Associate II

I am using STM32F072RB.

On my system there is 5 buttons(which is connected to GPIO).I am reading that GPIO continuously to detect the button press.

If there is no any button press detect for 10 min, I want to generate a alarm. And if any of the button pressed then timer should restart the counting from 0.

//to generate 1 second interrupt

timer = timer2

APB timer clock = 8 Mhz

htim2.Init.Prescaler = 8000-1;

htim2.Init.Period = 1000-1;

how to handle the timer for this case?

2 REPLIES 2
Uwe Bonnes
Principal II

Such long and not timing critical thing are better handle in the main programm loop waiting for a number of systicks to happen while some condition is active. Otherwise there is also a 32 bit timer in the F072 that allows such long waits.

Easier to use EXTI and a milli-second count down to generatre an alarm at expiry.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..