I have a strange error in my code that disappears when I try to debug it.
In my timer interrupt (the system ticker is always running), I have something like this:
if (a && lot && of && conditions) { some_global_flag = 1;
in my main loop i have
if (some_global_flag) { some_global_flag = 0; do_something_very_important();
This condition in the main loop is never called when the conditions in the timer are met (I think). Conditions are external (portpins, ADC results, etc.). First I set a breakpoint at position 1, and it never fires.
To test this, I set a breakpoint nr. 2 on the line some_global_flag = 1;
, and in this case the code works: both breakpoints start when the conditions are true.
Update 1:
In order to find out if any synchronization condition does not meet, and if
the timer is never entered if it works without debugging, I added the following to my timer:
if (a && lot && of && conditions) { some_global_flag = 1; // breakpoint 2 } if (some_global_flag) {
The flag in the code is not used anywhere. It is located in RAM, and RAM at the beginning is cleared to zero.
Now that all breakpoints are disabled (or only breakpoint 1 in the main part is turned on), the code does not work correctly, the function does not execute. However, if I only include breakpoint 3 in the NOP, the code works! The breakpoint starts, and after continuing, the function is executed. (It has a visible and audible output, so it is obvious if it works)
Update 2:
Timer interruption was interrupted by the "SEI" at the beginning. I deleted this line, but the behavior has not changed in any noticeable way.
Update 3:
I do not use external memory. Since I am close to the limit in the flash, I have maximum size optimization in the compiler.
Can the compiler (CodeVision) be responsible, or did I do something very wrong?