Solved
I want to change the period of a timer based on the 2 last pulses of a button constantly. How can I handle this
..
..
Like a tap for tempo detection in music?
Anyway...
Use the timer's input capture mode, which means the timer values are stored in the CCR registers when the button is pressed (or released, check the hardware, set the edge sensitivity of the capture accordingly).
If it's a button press made by a human being, you'll have enough time to use just interrupts:
button action 1st interrupt: reset timer counter to 0
button action 2nd interrupt: save timer counter value, then reset
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.