Shop OBEX P1 Docs P2 Docs Learn Events
Revisiting I/O Pins and Baud Rate: OT — Parallax Forums

Revisiting I/O Pins and Baud Rate: OT

YendorYendor Posts: 288
edited 2006-10-12 12:39 in General Discussion
I wanted do look more at the assembly code for the I/O pins from my post
"Delay, PIN Command, BaudRate Options & SX-Key Listing Feature Request" at http://forums.parallax.com/showthread.php?p=607062

That one got a little complicated, so I wanted to narrow down a couple of questions and try again, since I've had a chance to investigate a little more.

1.· Revisiting the PIN command
I did two versions of one program with the only difference in the two files was on pint was defined as:
MyOut1 PIN RA.1 OUTPUT


And then I changed the other file as:
MyOut1 VAR RA.1


I compiled each code and went to the SASM output directory and did a file compare.

The only differences was the SX/B code differences,·shown above and down further where the output field is accessed, which had

MOV W,#252· ; for the PIN RA.1 OUTPUT··· %1111_1100
MOV W,#254 ; for the VAR RA.1··············· %1111_1110

So do these SASM·constant impactin the TRIS register?··It seems logical as 0 is an output.·I guess I was expecting PIN·... Output to give more assembly differences.
Bean said...

Rodney,
The code to setup the pins is generated by the "PROGRAM" directive.
Bean.
Bean, I didn't quite understand what you were saying there.· Can you give a little more detail?

Also, if you are using a pin that's is·a bi-directional, would you declare it as a VAR, as in:
biCycle VAR RA.2 'bidirectional pin

2.· Revisiting·the difference betwen the T and the OT baud modes in the baud rate for SERIN/SEROUT, does the O refer to "Open Collector"?

Thanks!

Rodney


Post Edited (Yendor) : 10/7/2006 6:57:07 AM GMT

Comments

  • JonnyMacJonnyMac Posts: 9,071
    edited 2006-10-12 12:39
    When you use the PIN definition you'll get extra code at the end __PROGSTART section to set I/O pins according to the options specified. So the answer is yes, as you declared the pin an OUTPUT which requires a zero bit in the respective TRIS register. If you declare a pin using VAR the default, as with the BASIC Stamp, is input and you can manually change direction with the TRIS_X = value statement in your program (you can do this even if previously declared an output with PIN, PIN just saves you the initial setup step).

    Yes, the O in OT stands for open. For open true, the serial line needs a pull-up as the SX will only pull the line low (for a 1 bit), the pull-up takes it high for the idle state or a zero bit. For open inverted, the serial line needs a pull-down. By using open modes you can buss multiple devices on the same line without fear of an electrical conflict (you may scramble data if two devices talk at the same time, but there won't be a buss short).
Sign In or Register to comment.