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 support@ccsinfo.com

18F4550 and TX,RX

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



Joined: 16 Oct 2008
Posts: 59

View user's profile Send private message

18F4550 and TX,RX
PostPosted: Fri Jul 17, 2009 2:48 am     Reply with quote

Hi,
I have a PIC18F4550 and a RF module.
The RF module has one I/O (transmit, receive), which I connected to both RX and TX of the PIC. Meaning that TX and RX of the PIC are linked together.

I was wondering if it would be a problem, I mean, wouldn't TX bother the RX pin or something ?

For example, if I use fprintf for TX, and not read RX, I think it should be fine,
but if I use fgetc() for RX, wouldn't TX impose a high level ?

Should I use the TRIS function to set TX as an input when I use RX ?

If I'm not clear, please ask for more details.
Thank you.
Ttelmah
Guest







PostPosted: Fri Jul 17, 2009 4:06 am     Reply with quote

The problem is not with TX taking the RX line high. This is the required 'idle' level for TTL serial.
There are two problems. The first problem is how is the external module, ever going to take the line _low_, when it receives. The TX line is pulling the line high, when it is not talking. The 'answer' to this, is that you need to add a pull up resistor to the line, and then add the option 'FLOAT_HIGH', to your #use RS232 definition. This tells the compiler to switch the TX _off_ when it is not sending a byte. You need the pull up, since otherwise the line won't actully go high, when it is not being driven.
The second, is that whenever you send a character, you wll also receive this character, so your code will have to read this, and throw it away. How you do this, will depend on the 'nature' of your code. If you are using interrupt driven receive, then the code here will need to be told you are sending, and throw away characters during this time, _or_ be told what characters are being sent, and look for these, and throw them away. If instead your code is basically 'sequential', sending characters, and then waiting for a return, you can write an 'encapsulated' version of putc, which sends one character, and then reads the returned character, before exiting, and use this to send your data.

Best Wishes
magestik



Joined: 16 Oct 2008
Posts: 59

View user's profile Send private message

PostPosted: Mon Jul 27, 2009 1:41 am     Reply with quote

Sorry for the late response, just wanted to say that your solution worked like a charm.
Thank you ;).
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