View previous topic :: View next topic |
Author |
Message |
barton Guest
|
can serial use same pin? |
Posted: Thu Dec 14, 2006 3:05 am |
|
|
recently i using a GPS sensor from parallax.
sorry, i only a guest cant post link here. plz go parallaz.com to check
this sensor got 4 pin, 1 vdd, 1 vss, 1 raw.
last 1 is serial in and out..
IZ possible set the serial in and out use the same pin ?
iz set xmit= pin_C6, rcv=pin_c6 ? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Dec 14, 2006 8:46 am |
|
|
Sure you can use the same pin for serial TX and RX. I do that all the time. It requires using the software UART. The pin becomes an output when you execute putc(), and becomes an input when you execute getc(). _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
barton Guest
|
what is UART |
Posted: Fri Dec 22, 2006 10:39 am |
|
|
ty for ur infomation, btw, what is UART ?can some 1 send 1 sample with serial using UART ..
my email : senchuan82@ yahoo.com
the email add in combine |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Dec 22, 2006 11:05 am |
|
|
Most PICs have a hardware UART (Universal Asynchronous Receiver Transmitter as I remember) that is a kind of shift register specialized for serial communications. To transmit the uP loads a byte into the register and the UART clocks out the Start bit, the byte, and the Stop bit. The UART also waits for an incomming Start bit and when it sees that is clocks in the serial data and Stop bit. Since it is always ready to transmit or receive, or both simultaniously, it requires two pins for input and output.
CCS C can simulate the UART in software for chips that lack the hardware, or programs that need really odd UART configurations that the hardware PIC UART can't accept. Using the same pin for in and out is one of those odd configurations. The big downside of the software UART is all the ROM and processor time it takes. For example the processor has to be waiting for an incomming serial byte or it will be lost. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Fri Dec 22, 2006 4:12 pm |
|
|
Also, isn't it recommend to insert a small current limiting resistor like a 1k on the RX and TX to prevent a dead head short in some cases? |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Dec 22, 2006 4:25 pm |
|
|
I suppose the GPS device does not need incoming data all the time, this feature is rather for some setup purpose only.
I would suggest using a software UART for sending setup data (or other infrequent communcation going towards the GPS, like parameter change, etc.) and switch programmaticaly to the hardware USART during normal operation when you only receive GPS coordinates (most of the time)
Doing so you will not waste the the hardware USART's contribution to save processor time and have a more reliable program flow with interrupts when a full byte has arrived. |
|
|
|