Interrupt question

Hi,

I'm using the STM32F103ZD.

The TIM2_IRQHandler() interrupt handler decrements a value, checks for zero, if so does some action and (re-) sets this value to 1. So each call to this interrupt handler should execute some action.
Also higher priority interrupts are active.

If the program execution fails I see in the debugger that 'value' has decremented through zero to 0xffff and lower. Is this some atomic problem? Or is the interrupt handler somehow re-entered while executing?


// variabele declaration
volatile static unsigned short value=1;

// timer 2 interrupt handler
void TIM2_IRQHandler(void){
  // an update event is detected
  if(TIM2->SR&TIM_SR_UIF){
    // clear the update event interrupt flag
    TIM2->SR&=~TIM_SR_UIF;
    // decrement some value
    value--;
    // value is zero
    if (!value){
      // do something
      DoSomething();
      // preset value
      value=1;
    }//if
  }//if
}//TIM2_IRQHandler

Who can help me out?
Thanks
Henk

Parents Reply Children
No data
More questions in this forum