HI all. I am developing a programm with the demo version of the keill compiler.The µ-Controller is a cygnal 8051(c8051f124). I have faced a very strange behavior: int Pack_Counter=0; ... if(Pack_Counter>0){ ...//I set a breakpoint here } when i run the program it sometimes(strange again)stops at the breakpoint.When i watch the value of the variable it is 0 as it should->The Comparison is false->The program should not interrupt. BTW:I have some ISRs but there is none that changes the value of the variable. Does anyone have an idea?
"so it was no simulation which took place" but could be a problem in the JTAG interface and/or driver...
I don't usually use the Keil debugger instead of an ICE (Nohau). But at high optimization levels, the Keil optimizer is so aggressive that it wreaks havoc with the ability of the debugger to know which instruction matches which source line. The same instructions or snippets of code get reused for many C source lines. But there's only one "file / line number" assigned to any instruction, apparently the first one where it appears. So Seehau, at least, has fits doing source level debugging. It looks like it jumps to all sorts of irrelevant code, when in fact it's just following the optimized bits as best it can given the information available. As a concrete example, quite a few compilers and debuggers I've used will apparently "jump into" a early if in a procedure when it's the test-and-bail-out sort:
if (bad thing) { // unwind return; } // code presumed safe