Home > other >  Callback function variables tamper with the IAR interrupt
Callback function variables tamper with the IAR interrupt

Time:09-20

IAR wrote a STM8L051 program, in order to make the program modular, the callback function used in the timer interrupt the interrupt, (here please ignore in the interrupt function call is a waste of time, etc.), but found that interrupts the callback function of temporary variables tamper with the temporary variables in the main program, enter the interrupt time is arguably the main program temporary variables should be pressure stack, exit will restore the value of the temporary variables, but the actual add breakpoint debugging found that the main function of temporary variables or has been tampered with, don't know if you have encountered similar problems, a great god, please teach , debugging screenshot below

1 a for loop to create a temporary variable (I) a value of 0


In the first for loop and the second for loop between the timer interrupt, timer interrupt function calls the callback function, in the callback function to create a temporary variable I, I in the callback function value is added to 3


The second for loop of time I value should be 1, but at this time is 3, and interrupt the callback function inside the temporary variable I have the same value, in addition, the temporary variable memory address is defined in the 0 x00, don't know why
  • Related