Using #stm32 HAL_TIM_xyz for counting pulses with timer in external clock mode #stm32


Pauli
 

Dear all,

I am doing silly motor driver for worm-gear dc-motor with stm32f411e-disco board (and L298). The dc-motor has HAL-sensor for feedback - providing raising/lowering edge for every turn. Now, as the HAL sensor is attached before the worm-gear, so the RPM will be something. To have it handled with ease i was thinking to connect the HAL sensor output to STM32 as external clock input -> i can get the count from the timer register with zero load to processor.

As far as i know (and have tested - it compiles) i can use the HAL_TIM_XYZ functions and they should work -> i can use them to configure timer to be in external clock mode.

But how does one handle the overflow of the timer? In normal STM32 HAL code one would get interupt from this but i have no glue how to do it with Zephyr. I do know i could poll it with very little overhead, but that seems bit brute-force.

Would it be easy to set up interrupt handler for timer overflow? Could somebody point out tips what would be the steps required (or just say its not doable without weeks of work)? What Zephyr source files i should look at? Any change of samples that would even have some similarity?

BR,
Pauli

Join users@lists.zephyrproject.org to automatically receive all group messages.