CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

can serial use same pin?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
barton
Guest







can serial use same pin?
PostPosted: Thu Dec 14, 2006 3:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 14, 2006 8:46 am     Reply with quote

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
PostPosted: Fri Dec 22, 2006 10:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 22, 2006 11:05 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 22, 2006 4:12 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 22, 2006 4:25 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group