AnsweredAssumed Answered

Systick Delay functions

Question asked by jdcowpland on Jan 7, 2015
Latest reply on Jan 12, 2015 by Clive One
Hi folks,

I have had some code working for quite a while now using the sytick to create delay to the order of ms. This was made up of the following functions:
static uint32_t TimingDelay;
 
void Delay( uint32_t nTime)
{
  TimingDelay = nTime;
 
  while(TimingDelay != 0);
}
 
 
void TimingDelay_Decrement(void)
{
  if (TimingDelay != 0x00)
  {
    TimingDelay--;
  }
}
 
void SysTick_Handler(void)
{
  TimingDelay_Decrement();
}
With the systick config setup with the systemcoreclock/1000.

This all worked fine. What I am trying do now, is to introduce a us delay. I thought it should be as simple as changing the systick config to systemcoreclock/1000000, and creating a Delay_us() function, and then modifying my Delay() function to TimingDelay = nTime*1000;

This seems to encounter some issues where it never seems to leave the Delay function. The Delay_us function seems to work fine. Has anyone else ever implemented a similar idea?

Outcomes