STM32中的APB1外围时钟和APB1计时器时钟之间的区别是什么?
感谢您访问我的问题。 我现在正在尝试设置我的STM32设备(Nucleo STM32F401RE)以使用计时器,并发现计时器基于哪个时钟。 使用TIM2,因此时钟信号应来自APB1。
以下是我的时钟配置。
在这里我有一些问题。有两个时钟:APB1外围时钟和APB1计时器时钟。
这些区别是什么?为什么分开,一个是预级的,另一个没有?
tim2毕竟在哪个时钟上工作?
Thank you for visiting my question.
I'm now trying to set up my STM32 device(NUCLEO STM32F401RE) to use timer and found that which clock the timer is working based on.
TIM2 is used so the clock signal should come from APB1.
Below is my clock configuration.
Here I have some questions. There are two clocks: APB1 peripheral clocks and APB1 Timer clocks.
What's the difference of these? Why are these separated, one is prescaled and the other is not?
On which clock the TIM2 works based after all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
外围的配置寄存器,您可以通过APB1速度访问APB1和时钟计时器之间的区别,可以使时钟的计数器打勾。
这是STM32F401的RCC外围的时钟树部分,参考手册RM0368,第94页:
页面95:
之后,这是另一个有趣的部分:
最后一篇文章谈论的是不经常提及的配置,我通常默认情况下看过它,但是,嘿,您在这里有很多灵活性。
在默认情况下,如果APB时钟不等于系统时钟(IE APB预拉仪大于1),则计时器计时时钟会加倍。
因此,如果我的MCU以48MHz和APB1运行量也为48MHz,则我在48MHz访问计时器寄存器,并且Timer(在计时器Prescaler = 1)ticks ticks ticks 48MHz。
但是,如果我的MCU在84MHz下运行,但是我的APB1在42MHz下运行,那么我在42MHz中访问Timer的寄存器,但是计时器(计时器Prescaler = 1)在84MHz处滴答作响。
通常,当您的MCU处于最大系统时钟频率时,APB总线的预分级将大于一个,这意味着计时器的计数器以两倍的总线速度运行。
It can be the difference between peripheral's configuration registers, that you access via APB1 with APB1 speed, and the clock timer, that ticks the counter of the clock.
Here is a clock tree section of RCC peripheral of STM32F401 reference manual RM0368, page 94:
Page 95:
And right after that is yet another interesting piece:
The last piece talks about configuration that isn't often mentioned, I've usually seen it by default, but hey, you have quite a bit a flexibility here.
In default scenario, if APB clock is not equal to system clock (i.e. APB prescaler is greater than 1), then Timer counter clocks are doubled.
So if my MCU runs at 48MHz and APB1 is also 48MHz, I access timer's registers at 48MHz, and the timer (at timer prescaler=1) ticks at 48MHz.
But if my MCU runs at 84MHz, but my APB1 runs at 42MHz, then I access timer's registers at 42MHz, but the timer (at timer prescaler=1) ticks at 84MHz.
Very often, when your MCU is at max system clock frequency, APB bus will have a prescaler greater than one, meaning the timers' counters run at double their bus speed.