Hey guys,
I've been browsing the forums for a while, had my Plus for a few weeks now and haven't gotten any major projects going quite yet, but I'd like to interface with a temperature sensor (DS1620) that uses a 3-wire interface (clock, data, reset). I'm not too concerned about speed so bitbanging is fine by me, but I'm wondering if I can use a single GPIO pin for both reading and writing data to. Is this even possible? Can I create an output port, write the data, dispose it, then create the input port on the same pin to read the data? I basically just want to disable the output port from driving the line when I need to treat it as an input port. Any suggestions?
Thanks,
Scott
GPIO pin for both input and output
Started by scottyb84, Mar 07 2011 02:29 AM
3 replies to this topic
#1
Posted 07 March 2011 - 02:29 AM
#2
Posted 07 March 2011 - 07:45 AM
Hi Scott,
Yes, you can absolutely use a single port for both writing and reading data.
First option: create an OutputPort, use it, dispose of it, create an InputPort instead, use it, dispose it, repeat.
Second option: create a TristatePort <-- this will let you change the mode between read and write on the fly.
Welcome to the Netduino community,
Chris
#3
Posted 07 March 2011 - 03:04 PM
I suggest you use the TristatePort class. It is faster than creating an output and disposing then creating an input. Here is an example of how I used it http://forums.netdui...de-is-included/ and http://forums.netdui...ch__1#entry6511
- Chris Walker likes this
#4
Posted 07 March 2011 - 11:57 PM
TristatePort is exactly what I was looking for - thanks for the help!
-Scott
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users