CM4 systick 时钟源设置

发布时间 2023-07-31 15:51:21作者: LogicBai

CM4 systick 时钟源设置

起因

之前离职的同事交接给我的项目里面timer2的配置错误让我决定修改他用到的每一个时钟的配置。

systick 时钟源设置方法

systick 的时钟源可以从两个地方选择。

  • internal源
  • external源

The Cortex System Timer (SysTick) external clock is clocked with the AHB clock
(HCLK) divided by 8. The SysTick can work either with this clock or with the AHB clock
(HCLK), configurable in the systick control and status register.

上述是CM4 vendor(GD32)手册中表述的。

  • 如果systick 选择external源那么就是AHB clock的8分频
  • 如果systick 选择internal源就是AHB clock

源的选择在CM4指导手册中可见。

在SysTick Control and Status Register的中

CLKSOURCE

Indicates the clock source:

  • 0 = external clock
  • 1 = processor clock