2018-11-19 05:01 PM
I'm trying to set up a counter to capture the period of an input signal. I'm getting lost in the different CCMR bits. If it possible to do the following:
(e.g., I'm expecting a raising edge every 10,000 ticks of the timer. If the timer goes to 12,000, I'm going to decide that the signal failed to arrive. I want to reset the counter to 2,000 and keep counting from there, as if input capture did happen. I can use a counter compare interrupt and set CNT manually, but I don't know how to account for the ticks that happen while I'm in the ISR)
2018-11-19 10:03 PM
Which STM32?
In older, like 'F1 or 'F4, can't do 2 directly and you'd need to employ DMA; in newer, like 'L4 or 'F7, you can do all. This requires not only to read the CCMR bits description, but also the SMCR bits description (and generally the whole timer chapter in RM); you are looking for Combined reset + trigger mode of the slave-mode controller (mind the discontinuous SMS bits).
For the bonus points you'd simply use a compare in a different channel and reset and stop the timer in its ISR.
JW
2018-11-21 03:49 PM
Thank you. So far, I've been developing this on an F030, but I'm OK moving up to a bigger part if I need to.