Stm32 study note 4 (implementation of tim32-bit timer)

Source: Internet
Author: User
Discussion on 32-bit CPU and 16-bit timer of stm32


The universal timer of stm32 can implement many functions, such as timing counting, measuring the pulse width of external signals, generating PWM waveforms, and measuring input PWM waveforms. In all these operations, the number of digits of the timer mainly affects two parameters, one is the precision of timing or measurement, and the other is the time length of timing. Let's take a list to see the precision and length of the timing:



For more information about the functions of each pre-divider, see the right section:


It can be seen from the table that at the highest precision (14ns), the scheduled length is only 0.91 Ms. When the precision is 250ns (4 MHz), the scheduled length can reach 16.38 Ms. This is the case where only the independent working mode of the timer is used.

For applications that require high precision and long latency, 16-bit timing (the above precision and time length) is not enough. There are two solutions to this problem; the first method is to complete the task through the software relay. The feasibility of this method is that the timing time is long and the software is allowed to have enough time to intervene in the counting. This method is very convenient and can be used in most cases. The second method is to use the timer cascade function unique to implement the 32-bit counting effect, because cascade is triggered by hardware. After each register is set, the software does not have to intervene in the middle, so it can meet the requirements of high precision and long latency. In addition, stm32 can have a maximum of four timers. If they are connected in series, you can even achieve a 4*16 = 64-bit counting effect.

In simple terms, the cascade function enables a timer to start another timer when the timer conditions of a timer are met.

There is an app note and corresponding example program on the st website, the following describes how to use the cascading function of stm32 to capture 32-bit input and compare 32-bit output:
Application notes: http://www.st.com/stonline/products/literature/an/13711.pdf
Demo: http://www.st.com/stonline/products/support/micro/files/an2592.zip

This is the abstract of this application note:
[How does an2592 use the clock link function of stm32f101xx and stm32f103xx to realize the 32-bit precision of the timer?] (December August 2007)
Many applications require 32-bit precision, which is used to measure the cycle of an external signal over several hundred seconds and produce a delayed or large interval of periodic signals.
.
This article provides the basic principle of simulating a 32-bit timer, and introduces two basic operation modes: Input capture mode and output comparison mode. Each mode is described separately with instances attached.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.