I'm experimenting on the STM32F103 MCU and I'am surprised about what
this code does (in examples/other/systick/systick.c):
/* 72MHz / 8 => 9000000 counts per second */
/* 9000000/9000 = 1000 overflows per second - every 1ms one interrupt */
I've found that the LED does not toggle every 1s...
According to the comment and the symbol STK_CTRL_CLKSOURCE_AHB_DIV8,
systick'c clock source is core clock divided by 8.
Diving into the Core M3 datasheet, I've found that bit 2 of SysTick
control and status register selects the clock source, not a divider:
stk clk src = (STK_CTRL bit 2 == 1) ? core clock : ext ref clk
I do not know yet what is this external reference clock but I've tried:
and now the LED does toggle every 1s.
Maybe it would be wise to rename:
STK_CTRL_CLKSOURCE_AHB_DIV8 as STK_CTRL_CLKSOURCE_EXT
STK_CTRL_CLKSOURCE_AHB as STK_CTRL_CLKSOURCE_CORE
or something like that.
Tell me if I'm completely wrong, I need to learn!
> According to the comment and the symbol STK_CTRL_CLKSOURCE_AHB_DIV8,
> systick'c clock source is core clock divided by 8.
> Diving into the Core M3 datasheet, I've found that bit 2 of SysTick
> control and status register selects the clock source, not a divider:
> stk clk src = (STK_CTRL bit 2 == 1) ? core clock : ext ref clk
The reference manual from ST Microelectronics for STM32F10 (RM0008)
says in section 6.2 and 7.2:
"The RCC feeds the Cortex System Timer (SysTick) external clock with the AHB
clock (HCLK) divided by 8. The SysTick can work either with this clock or
with the Cortex clock (HCLK), configurable in the SysTick Control and Status
These names are STM32 specific, not Cortex-M3 generic.
*Black Sphere Technologies Ltd.*
Mobile: +64 27 777 2182
Tel: +64 9 478 8885
Get latest updates about Open Source Projects, Conferences and News.