3 Attachment(s)
Variables change depending on a SEROUT2 command placement in code
Hi all,
I've been spending a few hours now (this is an euphemism, of course :D) on trying to find out why the program I'm currently working on has his variables "changing" values without any obvious reason.
Let me explain.
In this first image, the green field shows correct values and the red one, the wrong values. Amazingly, the program works (by chance...) but the reported values by the SEROUT command are wrong (in the "red" case).
Attachment 8972
These values change depending on the placement of a few lines of code as you can see herunder.
Correct
Attachment 8973
NOT Correct
Attachment 8974
So, is there any scientific reason why my values change depending on the placement of the DEBUG (yellow frame) lines?
The variables Now and Prev are declared as BYTE and have respectively values 15 and 255 at program startup.
Thanks for any explanation that will stop me jump out of my window!!! Okay, I leave on the groundfloor...:wink:
Re: Variables change depending on a SEROUT2 command placement in code
Your Key_Cnt variable increments inside the IF condition and therefore, placing the SEROUT statement before the IF works correctly.
You need to investigate that IF statement with this in mind.
Re: Variables change depending on a SEROUT2 command placement in code
Thanks a lot Jerson :wink: