We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, There is a strange behavior in my project. I declare a global variable SwitchToBtFlag in project.h
#ifdef _project_c_ #define AUTOEXT #else #define AUTOEXT extern #endif, AUTOEXT volatile bit SwitchToBtFlag; #undef AUTOEXT
void fun_a( void ) { … if( condition ) SwitchToBtFlag = 1; else SwitchToBtFlag = 0; … } void fun_b( void ) { … if( SwitchToBtFlag ) { SwitchToBtFlag = 0; … } }
You could see that effect from an array index out of bounds, or bad pointer, potentially anywhere in the code. Moving the variable doesn't really fix the problem, but does change what gets stepped on. Check the old address of the variable in xdata and see if it is being written to. If you have an ICE with trace capability, (or a logic analyzer, if your xdata is really external), go back to the old code and set it up to trap writes to that address. Then see what address in the code is writing where it shouldn't.