View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
Using 2 uarts at once |
Posted: Tue Dec 18, 2007 3:24 pm |
|
|
I want to build a device that talks to 2 devices serially. They will be at different baud rates, and the only thing the pic needs to do is translate. Basically ready a few bytes at 19200, send them out the other port at 1Mb, then get a 1Mb response, and send it back at 19200.
My question is should I go with 1 uart, and a software uart, or find a pic like a 18f4680 that has 2 uarts? If I go with the 1 Uart I have to poll to get info from the SW uart, if I go with a 18f4680 , can I set up 2 different #int_RDA routines? How does that work?
Thanks
Ringo _________________ Ringo Davis |
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Tue Dec 18, 2007 3:53 pm |
|
|
To answer the 2nd part,
#INT_RDA
and then
#INT_RDA2
For the 1st part, 1M is pretty darn fast - not sure you can. Others?
Ken |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Dec 18, 2007 4:33 pm |
|
|
Are the communications full-duplex or half-duplex? i.e. is the sequence exactly as you described where there is only one action at a time (half-duplex), or is it possible you are listening at one port while transmitting at another port (full-duplex)?
In the half-duplex situation you could assign the soft UART to the 19k2 connection and use the hardware UART for the 1Mb connection. For a full-duplex it will be very difficult to implement with a software UART.
Either case: If you have the option open to choose a new chip with two hardware UARTs I would go for that as it makes writing the software a lot easier. A software UART does not generate interrupts and makes the software a lot more difficult. Price is not a criterium as a chip like the PIC18F65J10 with two UARTs is available for $2.15.
Note: the PIC18F4680 has only 1 hardware UART. |
|
|
|