STM32 Timer Clock problem

Source: Internet
Author: User

This article transferred from: http://www.cnblogs.com/daqiang/archive/2012/03/10/2389336.html

stm32f103 the APB1 maximum bus clock is AHB bus clock 1/2, the maximum is 36MHz, in the library function with St (v2.0), TIM2 (normal timer) clock frequency of 72MHz, do not know why?

"Problem Analysis"

There are up to 8 timers in the STM32, where the TIM1 and TIM8 are high-level timers capable of generating three pairs of PWM complementary outputs, often used for three-phase motor drives whose clocks are generated by the APB2 output. The other 6 are normal timers, and the clocks are generated by the APB1 output.

is the STM32 reference manual on the clock distribution diagram for the Timer clock section:


As can be seen, the clock of the timer is not directly from APB1 or APB2, but from the input of a multiplier of APB1 or APB2, the blue part of the figure.

The following timer 2~7 the function of this multiplier: when the APB1 prescaler coefficient is 1 o'clock, the multiplier does not work, the clock frequency of the timer is equal to the frequency of APB1, when the APB1 prescaler coefficient is another value (that is, the prescaler coefficient is 2, 4, 8 or 16), the multiplier function, The clock frequency of the timer equals the frequency of APB1 twice times.

Assuming Ahb=36mhz, because the maximum allowable frequency of APB1 is 36MHz, so the prescaler coefficient of APB1 can take any value, when the prescaler factor = 1 o'clock, the apb1=36mhz,tim2~7 clock frequency =36mhz (multiplier does not work), when the prescaler coefficient = 2 o'clock, Apb1=18mhz, the tim2~7 clock frequency is =36mhz under the action of the multiplier.

Some people will ask, since the need tim2~7 clock frequency =36mhz, why not directly take APB1 prescaler coefficient =1? The answer is: APB1 not only to provide the clock for the tim2~7, but also to provide clocks for other peripherals, set this multiplier can be used to ensure that other peripherals using a lower clock frequency, tim2~7 can still get a higher clock frequency.

Another example: When Ahb=72mhz, the APB1 prescaler coefficient must be greater than 2, because the maximum frequency of APB1 can only be 36MHz. If the APB1 prescaler factor = 2, the tim2~7 can still get a 72MHz clock frequency because of the multiplier. The ability to use a higher clock frequency has undoubtedly increased the resolution of the timer, which is why the multiplier was designed.

STM32 Timer Clock problem

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.