cancel
Showing results for 
Search instead for 
Did you mean: 

SysTick - SystemCoreClock - mismatch?

matthiasschwarz9
Associate
Posted on December 29, 2010 at 13:56

SysTick - SystemCoreClock - mismatch?

1 REPLY 1
Posted on May 17, 2011 at 14:19

Sounds more like a compiler optimization or code placement issue. Or the length of the test, and the granularity of your timebase.

Software timing loops are notoriously unpredictable, and will be compounded by placement with respect to the flash/cache lines.

For predictable timing, I'd use the core's cycle counter.

Something like this would generate more consistent code and placement between two compiles.

void SetSysTick(int i)

{

    SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

    if (i == 1)

      SysTick_Config(SystemCoreClock / 1000);    // = 1ms

    else if (i == 2)

      SysTick_Config(72000);                     // = 1ms

}

SetSysTick(1);

//SetSysTick(2);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..