Generate timer trigger upon change in counter value in Encoder mode.
Hi all
I am working on a time based velocity estimate from an incremental encoder. Currently its set up so that one timer is running in encoder mode, which works perfectly, the timer counts up and down fine through the full resolution of the encoder. I wanted this timer to generate a trigger event upon every timer counter change, which could trigger another free running timer to latch its value upon the trigger, generating a timestamp for that encoder event. This timer then generates two dma requests that move both the encoder value and the timestamp into variables in the code that can then be used for the velocity estimate. To generate these triggers the only way i have found is to set the trigger event selection for the encoder timer to Compare Pulse (OC1), this works to some extent. Triggers are generated and values are being latched, but its only every 4' encoder count that generates a trigger, this effectively removes 3/4 of the encoder resolution which is not optimal. In the reference manual its stated that the Compare Pulse (OC1) event triggers every time the CC1IF flag is raised, which to my knowledge should happen every time a value is captured in the CCR1 register.
From what i can gather in the reference manual there also exist the TI1F_ED trigger, which looks like it should generate triggers both on falling and rising edges from the signal. I can setup the trigger source on my timestamping timer to TI1_ED, however this still only latches every 4 counter value change on the encoder timer.
Is there a way i have overlooked, that can generate triggers on every counter change, or on all both rising and falling edges from the encoder signal? or is there maybe a workaround that can achieve the same behavior? Its not an option to utilize interrupts, since the cpu would be overloaded by these at higher speeds, where the encoder value is changing rapidly.
Looking forward to some input.
