japaric / stm32f103xx-hal

HAL for the STM32F103xx family of microcontrollers
Apache License 2.0
116 stars 40 forks source link

QEI Overflow #100

Closed gbip closed 5 years ago

gbip commented 5 years ago

Hi there ! I'd like to use the QEI mode the timers using some encoders which have 4096 ticks. The main problem is that the count() method of the QEI struct only returns a u16. And I don't see any way to get an interrupt when the timer overflow or underflow. How would you manage to do that ? Thanks a lot !

gbip commented 5 years ago

So to answer myself, this is not the best way to use a QEI. The best way is to sample the QEI often and to treat the overflow and underflow through software.

For getting the timer interrupt you can activate the cr.uie bit for your timer and register an interrupt through the interrupt! macro (from the device crate)