AnsweredAssumed Answered

Systick delay weird behavior. [STM32F103CB] [GNUArmEclipse]

Question asked by marsh.randy on Dec 26, 2015
Latest reply on Dec 26, 2015 by marsh.randy
I am experiencing weird behavior from my systick delay function.
The following code does not work.

void delay_ms(int time_ms)
{
     uint32_t time_done = SystemUptime+time_ms;
     while(SystemUptime < time_done)
     {
     }
}



However this one does:

void dummy(void)
{
     asm volatile("NOP");
     asm volatile("NOP");
}


void delay_ms(int time_ms)
{
     uint32_t time_done = SystemUptime+time_ms;
     while(SystemUptime < time_done)
     {
          dummy();
     }
}

If i use only one nop or do the nop without it being in a function it won't work. What am I doing wrong?

Outcomes