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

RS232 pin changing at runtime

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



Joined: 10 Jan 2008
Posts: 17

View user's profile Send private message

RS232 pin changing at runtime
PostPosted: Thu Nov 17, 2011 1:52 am     Reply with quote

I think this is a stupid question, but I desire to be sure before
change the PIC in the design because it will involve a delay...
I'm working on a PIC18F4525.
I was using the RS232.. but now it's necessary use two rs232 channel.

But I must use it not at the same time.
So is there a way to change only the pins of RS232 channel at runtime?

Thx in advance.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 2:54 am     Reply with quote

The PIC18F4525 has one hardware uart which can only work through one pair of pins, RC6 & RC7. You can't change the hardware.Shocked

You can have two serial channels, one hardware, one software, or both software. Configure them with two #use rs232() lines. There are loads of threads here about that.

Many people end probably up with two software serials without knowing it, and even a software one when they thought they were using the hardware.

Software serial channels are slow compared hardware, are blocking on receive, cannot receive unless your code is waiting for characters, are not true full duplex - they cannot receive and transmit at the same time - but they are very flexible - can work with any IO pins and do things like enables and other useful stuff. They are fine for transmit only and for half duplex applications and can be used for many protocol uses (where transmission and reception are carefully timed and in a predictable order. I've had MODBUS working over a sw serial port).

So, if you want to run one serial port most of the time and occasionally send something over another, or something similar then yes, it'll work fine. If you want full duplex fully buffered comms on two channels then you'll need two hardware UARTs.

RF Developer
FMOpt2000



Joined: 10 Jan 2008
Posts: 17

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 4:13 am     Reply with quote

Thx!
I found the software serial port, but your notes about slow and blocked connection lead me to a different solution.
I will introduce a DPDT to swap the connection outside the uC with a use of one pin.

I can't do better than that, or I need to change the uC.

Bye
Franco
Ttelmah



Joined: 11 Mar 2010
Posts: 19559

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 4:40 am     Reply with quote

Remember a second hardware port, does not need to be in the processor. Phillips do some little I2C UARTs. Also you could multiplex the I/O, using a logic gate rather than a switch. Whatever method you use though, remember that the RX line coming into the PIC needs to be biased high when not driven, including the moment the switch changes, and the TX lines into the circuitry 'beyond' the switch, also needs to be biased high when not driven.

Best Wishes
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