Port re not tracking with the I/O panel in SXSim
Bill Franke
Posts: 20
Hi, I'm a newbie to Parallax and have been doing a crash course on the SX52. I downloaded Guenther Daubach's latest SXSim but that did not seem to help my problem. I'm not sure if it is a bug in the sim, or my programming. I tend to think the latter.
Anyway, the problem I'm having is this: When I load port re with my final value, I then change the port direction back to input, but on the sim, re value doesn't change. It remembers the last value it had as an output. It remains different from the I/O panel settings for that port. I can "fix" the port settings by subsequently clicking the appropriate bits for that port on the I/O panel. Is this correct?
Here is the code I have.
Start
mov w,#$1F
mov m,w
mov !re,#%00000000 ; Set port D to output direction so I can directly store in the register
mov re,#%10101010
mov !re,#%11111111 ; Set port D back to input direction
Main
jmp Main ; In SXSim, at this point, re will still have %10101010 even though the I/O panel has all %00000000
Thanks for any help.
(Last night I posted this same message, but in the wrong forum, I think. - I also shortened the code.)
Anyway, the problem I'm having is this: When I load port re with my final value, I then change the port direction back to input, but on the sim, re value doesn't change. It remembers the last value it had as an output. It remains different from the I/O panel settings for that port. I can "fix" the port settings by subsequently clicking the appropriate bits for that port on the I/O panel. Is this correct?
Here is the code I have.
Start
mov w,#$1F
mov m,w
mov !re,#%00000000 ; Set port D to output direction so I can directly store in the register
mov re,#%10101010
mov !re,#%11111111 ; Set port D back to input direction
Main
jmp Main ; In SXSim, at this point, re will still have %10101010 even though the I/O panel has all %00000000
Thanks for any help.
(Last night I posted this same message, but in the wrong forum, I think. - I also shortened the code.)
Comments
handling inputs with SX-Sim and the I/O panel is a bit tricky. Your observations are right, and they are not only limited to port RE - the same is true for the other ports. This is definietely a bug in SXSim.
For example, after stepping through your sample code down to Main, see what happens when you click the RE.7 button in the I/O panel. You will notice that after that, RB.7 in the register display has changed to 0, which is what it is supposed to be. The problem is that the register display gets updated when the status of inputs in the I/O panel change but not when the status of a port dircetion bit is changed. I think it should not be too complicated to fix this one.
On the other hand which level shall SXSim assume on an input pin - high, low, or floating. Right now, the I/O panel simulates that pins are either tied to low or high, depending on the status of the assigned button. In reality, you don't have an I/O panel - there may be inputs with pull-ups, pull-downs, and even floating inputs (worst case). Seems as if I have to do some more work on the I/O panel.
Nevertheless, your reported bug is in my TODO list, and I'll fix it before the next version of SXSim is released.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
I really like your SXSim by the way, it sure makes debugging easier.
Bill Franke
I was just thinking . . . Could you make the I/O panel inputs three state? Right now you have them click green and red. Why not have a third option (I'd pick yellow) that comes up with a random on or off state just like it would in real life for a floating input?
It might also be nice to be able to turn this feature off so we wouldn't always have to click through all three states when most of the time we would only need two.
Keep up the good work.
Bill Franke
I like the idea making the I/O panel input controls three state (at least as an option). Let me see what I can do...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G