Question
How to get the correct value of SysTick->VAL on STM32F103 board?
Posted on October 21, 2014 at 18:54
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;
}
#stm32f103 #lmgtfy