AnsweredAssumed Answered

Is Systick the way to generate a delay function

Question asked by CS on Apr 12, 2013
Latest reply on Apr 16, 2013 by CS
Hi Folks (and Clive)
I have generated timing delays using systick and I want some comments on whether it was the right way to go:-

GPIO_InitTypeDef GPIO_InitStructure;
static __IO uint32_t TimingDelay;


void Delay(__IO uint32_t nTime)
    {
    TimingDelay = nTime;
    while (TimingDelay != 0)
     ;
    }


void TimingDelay_Decrement(void)
    {
    if (TimingDelay != 0x00)
     {
     TimingDelay--;
     }
    }

extern "C" void SysTick_Handler(void)
    {
    TimingDelay_Decrement();
    }

I believe that systick is a low priority - so can this code get stuck if there is a pending higher priority interrupt??

CS

Outcomes