I inherited a project to develop and I have a problem with debugging.
When I put a breakpoint (or do "suspend") the software does not resume working properly.
I give an example with the code:
if(locVBatt >= VBATT_MAX_OFF)
batSts = BAT_FILT_OVERV;
else if(locVBatt <= VBATT_MIN_OFF)
batSts = BAT_FILT_UNDERV;
vCnt = RESET;
I put a breakpoint inside the first "if" (let's say it's "true"), then restart code execution. The brekpoint continues to run ad always enters the first branch.
Then I move the brekpoint into the "else if", change the conditions so that it is "true" but never enters the "else if" but continues to enter the first "if".
Obviously if I create the conditions that it is true the "else if" at the first execution works correctly.
Same thing if instead of a brekpoint I make a normal "suspend" during the run.
It just seems that the software does not resume working properly, I have never seen such behavior and I really don't know how to fix it.
Thank you very much to those who can help me
I did but nothing changed.
There seems to be some configuration options, but I don't know which ones....
I just add a little information that might be helpful:
Looking at the previous code example (I put numbers), the starting condition is the following:
so putting a brekpoint it enters in the correct branch.
if I try to change the value of the variable AFTER stopping the code with a breakpoint and advancing step-by-step the software seems to ignore the new value and continues to enter the previous branch:
I'm not able to reproduce it.
Does the variable change in the memory view?
Can you read it in the memory before the condition is executed?
Is it a global variable or is it on the stack?
At the end of my investigation it seems that the whole problem stems from the fact that the Autonomous Periodic Interrupt continues to be active during debugging, triggering its interrupt when time expires and then setting an internal error that resets some variables.
Now we are a bit off topic from the original topic, but is it possible to disable it during debugging?
In my debug coonfiguration I've set this option, I hoped was enough
Yes, this disables it during the stepping through the code, but not while you are debugging.
It should be disabled by default though.
Was it enabled in your original configuration?
When you let the code run without stepping, doesn't the API overwrite the variables too?
You can disable the API interrupt at the first breakpoint by writting to the (CPMUAPICTL_APIE = 0) register via the debugger.