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

USB & RS232 Question

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



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

USB & RS232 Question
PostPosted: Fri Sep 01, 2006 4:07 pm     Reply with quote

Hi,

I have a PIC18F series and I use a USB to Serial (CP2102) for the USB connection, but my product have USB and Serial connector and I need to know if is possible connect the USB and MAX to the same UART from my PIC. Today I use a Jumper for selection of USB or Serial and I want that this was automatic.

Is possible this?, Anybody can tell me a idea about this.

Thank you very much!!!

Best Regards,
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 01, 2006 6:22 pm     Reply with quote

You only need to multiplex the receive lines into the PIC. The Tx out can be connected to both simultaneously.

You use a single PIC output to select either the USB or MAX chip either via using three analog gates (3 of the 4 in a CD4066) or by using 4 gates of a 74HC00.

sample pinout using 74HC00:

Pin 1 to 2 to 4 to PIC I/O select line (should really also have a pullup resistor )
Pin 3 to Pin 12
Pin 5 to USB RX output
Pin 6 to 9
Pin 7 ground
Pin 8 to PIC Rx pinn
Pin 10 to 11
Pin 13 to Max 232 Rx output
Pin 14 to VDD

When config when the PIC select line goes high the USB device is selected and low the rs232 device is selected

Alternatively you could implement a software UART for the RS232 port in which case you could send and received with both devices simultaneously (sending the identical output to both).
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
bwgames



Joined: 21 Jul 2005
Posts: 36

View user's profile Send private message

PostPosted: Mon Sep 04, 2006 3:56 am     Reply with quote

Another way, and the way I use, is to use a analog switch for the RX line. This has the advantage of simply requiring power connections, one wire to PIC, and two wires to the USB/serial connectors.
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Sep 04, 2006 6:06 am     Reply with quote

bwgames wrote:
Another way, and the way I use, is to use a analog switch for the RX line. This has the advantage of simply requiring power connections, one wire to PIC, and two wires to the USB/serial connectors.


How is this different?

Quote:

You use a single PIC output to select either the USB or MAX chip either via using three analog gates (3 of the 4 in a CD4066)

_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
bwgames



Joined: 21 Jul 2005
Posts: 36

View user's profile Send private message

PostPosted: Mon Sep 04, 2006 8:08 am     Reply with quote

Oops sorry, you're quite right, only noticed the NAND gate (74HC00).

Although it may be worth looking at something like a SPDT analog switch (part number escapes me at the moment) in which case you would only need one switch.
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PostPosted: Mon Sep 04, 2006 8:13 am     Reply with quote

Hi,

thank you for your answer, but this solution not is possible for my hardware. I need that the user connect the USB or RS232 and in my PIC receive the command for the only one UART, the PIC not select the port, the User select the PORt.

You are understand??

Thank you.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Mon Sep 04, 2006 10:13 am     Reply with quote

There are a couple of ways to solve this problem that I've used. They also are dependent on whether you plan on having the two cables connected at once...?

1. If your application allows the use of a custom serial cable:

I typically only use Tx, Rx, & Gnd so that leaves plenty of unused pins. Tie two unused pins together to form a jumper when you connect the custom serial cable to your application. On your board route Vdd through a 10K resistor to one of the pins that is jumpered. The other pin is routed to the logic driving the MUX between USB and Serial. By default USB is selected, however, when you connect the custom cable it drives the MUX to switch to serial.

2. If your application doesn't allow a custom serial cable, but you can guarantee your PC application will drive DTR or RTS:

You can use DTR or RTS to drive your MUX logic. Once again, USB will be the default selection. When you connect a serial cable the DTR or RTS signal can be used to swap the MUX over to serial.

There are lots of creative ways to solve the problem. If you give more details about your requirements you'll get a bunch of great ideas from the pros.

Good luck,

John
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