AnsweredAssumed Answered

Interrupt cant set global variable?

Question asked by wa.joans on Mar 13, 2013
Latest reply on Mar 24, 2014 by liewlom.peeya
Hi all. 

I got a problem: Every time i am setting a global variable in my ISR it is set to 0 after the ISR has ended!

volatile int test; 

void main(void)
{
     TIM1_DeInit(); 
     TIM1_TimeBaseInit(10, TIM1_COUNTERMODE_UP, 20000, 0);
     TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE); 
     TIM1_Cmd(ENABLE); 
  /* Infinite loop */
     enableInterrupts();
     
  while (1)
  {
          test = test;
  }  
}

INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
  test = 1 ;
}

Test is always 1 in the ISR but always 0 in the main??.. WHY??

Thanks in advance :) 

Outcomes