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?
"I have fixed the problem,not knowing exactly what went wrong..." If you don't know what exactly was wrong then you probably haven't fixed the problem. Most likely you've changed a bit of code and masked the problem for now, sometime later you'll change another bit of code and the problem will reappear, quite probably in a different part of your program. I find that taking the time to figure out exactly what is causing a strange problem is almost always worthwhile - it'll save you time in the long run. Stefan
In several cases I have seen similar occurrences when using data type variables. Using a Hitex emulator I ahave stepped through assignment of a value to a variable ( register was used by the compiler for the data variable in this case) and the assignment did not work. The variable did not get the value and the register used did not change to the assigned value. Using indirect addressing worked correctly in thes cases so where the problem showed up I am now using idata or xdata variables. It takes more memory and execution time, but at least works correctly