cancel
Showing results for 
Search instead for 
Did you mean: 

SysTick Interrupt suddenly dissapears

lattner
Associate II
Posted on May 22, 2015 at 08:11

Hi Folks!

I have a Problem with the Systick Timer. I use it to handle some periodic functions. The SysTick Timer is configured to 500us. Everything works fine. Now I need a delay function. When I start go into my delay function, it seems that the systick interrupt does not happen anymore. It is ending in an infinite loop, but the uC is still working because, i generate an interrupt with rtc (1s) and this one is still appearing Did anyone faced a Problem like this? Here is some Code

volatile uint16_t sysTickGlobTime = 0;

void BOARD_DelayMS(volatile uint8_t ms);

void SysTick_Handler(void) {
SM_Handler();
if(++time_1ms == 2) { //1ms
time_1ms = 0;
sysTickGlobTime--;
 }
}
void BOARD_DelayMS(volatile uint8_t ms) {
sysTickGlobTime = ms;
while(sysTickGlobTime!=0);
}

I'm using STM32F105RC and standart periph lib Many thanks for help!
3 REPLIES 3
stm32forum
Associate II
Posted on May 22, 2015 at 14:12 This works for me:

void InitDelay(void)
{
SysTick_Config(SystemCoreClock/1000);
}
/** @brief Delay
*
* @param nTime __IO int32_t
* @return void
*
*/
void Delay(__IO int32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
void SysTick_Handler(void) //Systick nvi handler
{
TimingDelay_Decrement();
}

Posted on May 22, 2015 at 14:52

And are you calling the delay function within some other interrupt?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock
Associate III
Posted on May 22, 2015 at 19:02

One potential problem is if the test

while(sysTickGlobTime!=0);

misses the zero condition because of something else going on.  What does SM_Handler() do?  Are there other tasks running?  If you are using a pre-emptive RTOS there's no guarantee you will catch the variable at exactly = 0x0000.  A 1ms time slice will make it extremely unlikely your while loop will ever exit.

If your test only sees = 0x0001 followed by =0xffff it's an effective infinite loop.  Make the variable signed and check for <= 0 instead.

  Jack Peacock