cancel
Showing results for 
Search instead for 
Did you mean: 

Systick Calibration

nickabrham
Associate II
Posted on April 19, 2012 at 14:29

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,

Nick
5 REPLIES 5
frankmeyer9
Associate II
Posted on April 19, 2012 at 15:41

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

).

Posted on April 19, 2012 at 15:47

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 19, 2012 at 15:48

Beat me to the post there.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
amin23
Associate II
Posted on April 19, 2012 at 15:57

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 = 1ms

nickabrham
Associate II
Posted on April 20, 2012 at 06:31

Hi Everyone

,

Thanks to all of you for explaining and giving solution to my query.

Regards,

Nick