AnsweredAssumed Answered

How to get the correct value of SysTick->VAL on STM32F103 board?

Question asked by lemoussel.christian on Oct 21, 2014
Latest reply on Oct 29, 2014 by lemoussel.christian
Hi all,

With this code I can not get the right number of tick.
I suspect the tick timer has not been initialised correctly.
I do not know why !

Do you have some idea ?

int main(void)
{
    /* Setup SysTick Timer for 1 msec interrupts */
    while(SysTick_Config(SystemCoreClock / 1000));
     
    SleepMilliseconds(5000); // Wait 5 Sec;
}
 
void SleepMilliseconds(delaytime_t ms)
{
    systemticks_t    currenttm, starttm;
 
    starttm = gfxSystemTicks();
 
    do { currenttm = gfxSystemTicks(); }
    while (currenttm - starttm < ms);
}
 
/**
* @brief Gets a "tick" time from the hardware.
* @param None
* @retval a "tick" time
*/
systemticks_t gfxSystemTicks(void)
{
    return SysTick->VAL;
}

Outcomes