0
votes

I need to implement on a STM32 ARM Cortex-M0+ (STM32L072KB) a frequency measurement for an external sine signal which is already digitalized with a comparator circuit. Unfortunately on my MCU the only timer I can connect to the COMP1/2 output is the LPTIM1 peripheral (Low Power Timer 1) and this special timer has no support for an input capture mode. It is still possible to set the LPTM1 in counter mode and create an interrupt after each pulse, but I don't think this approach is a good idea in terms of performance and accuracy.

My MCU runs at 2 MHz and the LPTIM1 can either set to this clock or LSI (=37kHz). The pulses I measure are nondeterministic (its came from the rotation of a gear) and can vary from a speed of 1 to 10.000 Hz.

Therefore, I want to ask if someone knows a better approach to accomplish a precise frequency measurement with the LPTIM1?

1

1 Answers

0
votes

The comparator output can be connected to the external trigger (ETR) signal of LPTIM, and the timer can count the pulses on that signal. Then you can read the counter value in a periodic interrupt handler.