cancel
Showing results for 
Search instead for 
Did you mean: 

SysTick maths?

agilmore19
Associate II
Posted on November 11, 2010 at 22:36

Hi, I can get SysTick working, but the maths for timing elude me.

I have

SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);

    if (SysTick_Config(SystemCoreClock / 20000))

    {

      /* Capture error */

while(1);

    }

System is running at 24MHz and SysTick at 3MHz (/8).

I just toggle a led in the interrupt routine.

void SysTick_Handler(void)

{    STM32_Discovery_LEDToggle(LED4);   }

As I understand it the systick timer is being clocked at 1/3MHz and the divider above (24MHz/20,000 = 1200) should give me a repition rate of .33usecs * 1200 = 400usecs., but the led is switching every 60 usecs.

I've obviously missed something, but what?

I'm using the RM0041 reference manual for the device and although it refers to the SysTick registers it doesn't describe them in detail as it does for the RCC registers. Have I the wrong manual?

Thanks for your help

Alastair

3 REPLIES 3
Posted on November 12, 2010 at 01:49

SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);

 

    if (SysTick_Config(SystemCoreClock / 20000))

 

    {

 

      /* Capture error */

 

while(1);

 

    }

 

You'll need to change the order of that, because SysTick_Config() sets the clock source to be HCLK

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
agilmore19
Associate II
Posted on November 12, 2010 at 12:36

agilmore19
Associate II
Posted on November 12, 2010 at 14:13