Tutorial : using a STM32L0 MCU for measuring a signal frequency with a 32 bit resolution (PART2)

Document created by jean-christophe Toussaint on May 12, 2018Last modified by jean-christophe Toussaint on May 19, 2018
Version 4Show Document
  • View in full screen mode

This tutorial is dedicated to students and engineers. 

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


Jean-Christophe Toussaint @ phelma  Grenoble-INP

full professor at Phelma Grenoble-INP University

1 person found this helpful