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.
I have a problem with hardware simulation using the Cygnal JTAG adaptor. I have code with the following structure: bit mState = False; void main (void) { [Configuration Code] while(True) { if (mState) { [Execute some code] } } } void ISR_Routine (void) interrupt INT_EX0 using 3 { mState = True; } This works fine for hardware simulation. However, when I add a second-level 'while' loop: bit mState = False; void main (void) { [Configuration Code] while(True) { if (mState) { while (!Condition1) { [Execute some code] } } } } void ISR_Routine (void) interrupt INT_EX0 using 3 { mState = True; } Now, in hardware simulation, the interrupt doesn't fire when the external interrupt is active. However, if I stop the simulation and cycle the power to the processor, the code runs fine. Is there a way I can get this structure to execute in hardware simulation? Thanks for your help!
Please re-post your code, following the instructions about using the pre and /pre tags - then we'll be able to read it!
I have a problem with hardware simulation using the Cygnal JTAG adaptor. I have code with the following structure:
bit mState = False; void main (void) { [Configuration Code] while(True) { if (mState) { [Execute some code] } } } void ISR_Routine (void) interrupt INT_EX0 using 3 { mState = True; }
bit mState = False; void main (void) { [Configuration Code] while(True) { if (mState) { while (!Condition1) { [Execute some code] } } } } void ISR_Routine (void) interrupt INT_EX0 using 3 { mState = True; }
I think the core problem of your code is that you forgot to mark 'mState' as volatile. Every variable shared between independent threads of execution, in particular between an interrupt handler and the rest of the code, must be volatile, or hell will break loose sooner or later.
Thank you! That solved the problem. Regards, Brian