2019-06-23 10:52 AM
Hello there.
I have an encoder connected to timer 3 (TIM3) and I'd like to set this timer to generate an interrupt when a certain amount of ticks have been reached (1658 ticks). I'd like to program the timer's counter to 1658 ticks and let the encoder count up to this value and generate an interrupt. I'm using the STM32F7 using the CubeMX generator.
Could somebody please point me in the right direction in how I could achieve this please?
2019-06-23 11:53 AM
If you need to count say 1658 falling edges and the timer is only used for this, then connect the source to channel 1, 2 or ETR pin, and use the signal a timer counter clock which will increment until reaching the value you want. Say the overflow value (update event) will kick an interrupt event.
2019-06-23 01:14 PM
There isn't a method of the timer counting the ticks and then generating a single interrupt once 1658 falling edges have been detected. I had it in my head I could set the CCR register to 1658 and once this has been reached, generate a interrupt.
2019-06-24 06:17 AM
Yes, you can do that. The CCRx and ARRx registers behave just like any other timer mode to generate update or compare interrupts.