STM32中的APB1外围时钟和APB1计时器时钟之间的区别是什么?

发布于 2025-02-10 06:29:41 字数 461 浏览 3 评论 0原文

感谢您访问我的问题。 我现在正在尝试设置我的STM32设备(Nucleo STM32F401RE)以使用计时器,并发现计时器基于哪个时钟。 使用TIM2,因此时钟信号应来自APB1。

总线信息

以下是我的时钟配置。

时钟配置

在这里我有一些问题。有两个时钟:APB1外围时钟和APB1计时器时钟。

  1. 这些区别是什么?为什么分开,一个是预级的,另一个没有?

  2. 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.

Bus info

Below is my clock configuration.

Clock config

Here I have some questions. There are two clocks: APB1 peripheral clocks and APB1 Timer clocks.

  1. What's the difference of these? Why are these separated, one is prescaled and the other is not?

  2. On which clock the TIM2 works based after all?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永不分离 2025-02-17 06:29:41

外围的配置寄存器,您可以通过APB1速度访问APB1和时钟计时器之间的区别,可以使时钟的计数器打勾。

这是STM32F401的RCC外围的时钟树部分,参考手册RM0368,第94页:

页面95:

“在此处inter

之后,这是另一个有趣的部分:

最后一篇文章谈论的是不经常提及的配置,我通常默认情况下看过它,但是,嘿,您在这里有很多灵活性。

在默认情况下,如果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:

enter image description here

Page 95:

enter image description here

And right after that is yet another interesting piece:

enter image description here

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文