2012-04-19 05:29 AM
Hi,
I want to generate 10ms systick. According to the example code provide with the StdPeriph_Lib_V3.5.0 i.e. \Project\STM32F10x_StdPeriph_Examples\SysTick\TimeBase, the systick of 1ms can be easily generated by the following code if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } I am running my STM3210E-EVAL at 72MHz. I was wondering how the following SysTick_Config(SystemCoreClock / 1000) could generate 1ms systick interrupt when the clock frequency is 72MHz. Kindly also tell me what divisor should I use in SysTick_Config function to generate 10ms interrupt. bye, Nick2012-04-19 06:41 AM
I suggest to debug into the SysTick_Config() function, and/or read the reference manual.
SystemCoreClock is the frequency the core is clocked with - 72MHz in your case. (SystemCoreClock/1000
) means, you get a SysTick interrupt after 72.000.000 / 1000 timer counts. This way, the divisor gives you the number of SysTick interrupts per second. For 10ms, which means 100 ticks / sec., you need (SystemCoreClock/100
).2012-04-19 06:47 AM
A millisecond is 1/1000 th of a second, 10 ms is 1/100 th.
SysTick_Config(SystemCoreClock / 100) Remember the SysTick clock is ticking in 1/72000000 th of a second units, unless you have it in HCLK/8 mode. You're counting the number of ticks that 10 ms would take.2012-04-19 06:48 AM
Beat me to the post there.
2012-04-19 06:57 AM
Hi,
To generate 10ms interrupt set the SysTick Reload Value register to (SystemCoreClock/100) that is mean SysTick_Config(SystemCoreClock / 100). here below an example: e.g: SystemCoreClock = xxMHz - SysTick interrupt period = the Reload Value register divided by clock frequency = (SystemCoreClock/1000)/SystemCoreClock = 1/1000 = 1ms2012-04-19 09:31 PM
Hi Everyone
,
Thanks to all of you for explaining and giving solution to my query. Regards, Nick