How to achieve 32-bit timer resolution using the link system
in STM32F10x microcontrollers
Introduction
In many applications, 32-bit resolution is required to measure external signal periods of up
to several hundreds of seconds or, to generate delays or periodic signals with large periods.
The STM32F10x microcontrollers offer the possibility of chaining two 16-bit timers to obtain
a 32-bit resolution based on a specific configuration of the timers and on the use of the timer
link system.
This application note gives general guidelines to emulate a 32-bit timer. The two basic
operating modes, that is the input capture mode and the output compare mode, are
presented. Each mode is treated independently and, each time, examples of applications
are provided.
In the STM32F10x microcontrollers, the embedded timers can be linked together for timer
synchronization or chaining purposes.
Using the timer link system, a timer configured in Master mode can:
●reset the counter of the slave timer
●start and/or stop the slave timer counter
●clock the slave timer counter
1.2 How to synchronize two timers using the link system
In addition to the TIMx_CHx pins, timers have several internal triggers that are
indispensable for linking and chaining operation.
Figure 1 shows a simplified representation of the timer block, that highlights the internal
triggers. TIM2 is used as an example.
Figure 1.Simplified TIM2 trigger controller block
The internal triggers (ITR0, ITR2 and ITR3) are used when TIM2 is configured in the Slave
mode. They then determine which master controls TIM2.
Doc ID 13711 Rev 25/17
STM32F10x timer synchronizationAN2592
For example, if TIM2 uses ITR2 as an internal trigger, this means that TIM2 is synchronized
with TIM3.
These triggers can be easily redirected to the master by setting the right combination of TS
bits in the SMCR register.
The trigger output, TRGO, is used when TIM2 is configured in the Master mode. It then
determines which events or signals is sent to the slave timers for synchronization.
Different events or signals can be transmitted to the slave, as listed below. They are selected
using the MMS bits in the CR2 register.
●reset event
●enable event
●update event
●compare pulse
●OCxREF where x is 1, 2, 3 or 4.
Once the master trigger output, TRGO, and the slave’s internal triggers, ITRx, are
configured, the two timers are chained.
There are four different slave modes that are selected using the SMS bits in the SMCR
register. They are the following:
●Reset mode: in this mode, the rising edge of the trigger signal reinitializes the counter
and generates an update of the registers.
●Gated mode: the slave counter start and stop are both controlled by the high level on
the trigger input.
●Trigger mode: the start of the slave counter is controlled by the rising edge of the trigger
input signal.
●External clock mode1: the slave counter is clocked by the rising edges of the selected
trigger input signal.
6/17Doc ID 13711 Rev 2
Loading...
+ 11 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.