PDA

View Full Version : Variables change depending on a SEROUT2 command placement in code



flotulopex
- 13th December 2020, 20:47
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).

8972



These values change depending on the placement of a few lines of code as you can see herunder.

Correct
8973

NOT Correct
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:

Jerson
- 14th December 2020, 05:59
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.

flotulopex
- 14th December 2020, 08:13
Thanks a lot Jerson :wink: