In a previous tutorial, the input capture technique was used for measuring the frequency of a PWM signal.
The timer TIM2 was configured for capturing two rising consecutive edges but its resolution is limited to 16 bits.
This implies that the two edges are at most separated by 0xFFFF cycles. In the opposite case the frequency estimation is therefore mistaken. Unfortunately for Cortex M0 based stm32 mcu neither any 32 bits timer nor the dwt cycle counter are available.
The solution proposed here consists in using jointly timer interrupts for capturing IC and Update events and is based on the application note AN2592.
Two versions of the test program are provided based on HAL and LL drivers.
The following equipment is used
-nucleo l053r8 Board or equivalent which owns only 16 bits timers.
- Eclipse with the necessary packages for Nucleo boards installed
- OpenOCD or STLink USB Driver - stm32cubemx 4.25.1