View previous topic :: View next topic |
Author |
Message |
Manel28
Joined: 06 May 2010 Posts: 33
|
UART Expansor |
Posted: Thu Oct 06, 2011 3:36 am |
|
|
Hi,
I recently bought a embedded ethernet development kit with a PIC18F4620 inside and 1UART. I was thinking about how can I expand serial communications since I need to use 3 rs232 ports. Maybe 1 hardware UART and the other 2 software UART? I don't know if exists kind of UART expansor device so that it can be contolled via I2C. I'm not pretty sure if it's too much for the pic to manage 3 independent serial communications plus the SPI bus for the ethernet controller :s.. recommendations?
Thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Thu Oct 06, 2011 4:52 am |
|
|
Yes.
Philips, does a little I2C UART.
Several other manufactures do as well (Maxim for example), but cost is higher, and availability may be 'dubious'....
Look at:
<http://www.datasheetarchive.com/SC16IS762-datasheet.html>
for the Philips family
Forget about using the software UART, unless:
1) Only one thing is ever talking at a time, and half duplex.
2) You can disable interrupts for the whole of a character time (unlikely if dealing with a network).
With the buffering on these, you can drive them with software I2C (since you are using the MSSP port already), and should still be OK.
Best Wishes |
|
|
n-squared
Joined: 03 Oct 2006 Posts: 99
|
|
Posted: Thu Oct 06, 2011 4:57 am |
|
|
Hi
As I see it, you have two choices:
1. stay with the PIC18F4620 and implement 2 USARTs in software.
2. replace the MCU with PIC18F46K22 which has 2 USARTs and implement a 3rd UART in software.
CCS provides software based serial drivers which are mainly good for transmission.
For reception, it is better to implement the USART using an external interrupt pin in conjunction with a timer.
BR
NN _________________ Every solution has a problem. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Thu Oct 06, 2011 5:40 am |
|
|
Also consider the speed( baud rate) thet you need.If slow compared to cpu clock, software UARTs might be fine for you application.Microchip did an application of a serial mouse and used some nice tricks a long,long time ago. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Oct 06, 2011 6:20 am |
|
|
I don't recommend software based UARTs unless it is for half duplex debugging purposes only and you don't mind an occasional corrupted character. I've done a software UART in a commercial product where we needed an extra UART, it is working, but only up to 19.6kbaud and took a _lot_ of time to get the last bugs removed. For another project we added the external NXP UART that Ttelmah is recommending, this worked great.
Technology has progressed and since you are starting a new project you might consider another chip family that has more UARTs built in, for example the PIC24FJ64GA106 has 4 UARTs.
Prices for the components at DigiKey:
PIC18F4620 ($7.80) + external UART SC16IS762 ($5.60) = $13.40
or:
PIC24FJ64GA106 = $5.82
Funny, I didn't realize the PIC24 with much more advanced hardware and larger memory is even cheaper than some PIC18 models. One disadvantage is that you will need another version of the CCS compiler, the PCD compiler. |
|
|
Manel28
Joined: 06 May 2010 Posts: 33
|
|
Posted: Thu Oct 06, 2011 6:20 am |
|
|
n-squared I was thinking of the first option, stay with then PIC18F4620 and implement the other 2 in software as long as long as i use this development kit.
The idea is just to buy another PIC with 2 UART (PIC18F46K22 is an option) and implement the third one in software. Actually I don't need the software UART to receive data since the transmission will be done in one direction..so It will probably work out. The other 2 hardware UART are used in full-duplex mode.
I gonna use a 10MHz crystal with PLL to 40MHz clock. Thats what I need for the Ethernet controller to work fine.. All 3 UART musst work at 57600bps.
I haven'u used software UART so far but it shouldn't be complicated, something like
#USE RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, STREAM=COM1)
#USE RS232(BAUD=9600, XMIT=PIN_B0, RCV=PIN_B1, STREAM=COM2 )
#USE RS232(BAUD=9600, XMIT=PIN_B2, RCV=PIN_B3, STREAM=COM3 )
I don't know if I'm missing something . Thanks for the help |
|
|
Manel28
Joined: 06 May 2010 Posts: 33
|
|
Posted: Thu Oct 06, 2011 6:31 am |
|
|
ckielstra I hadn't read you. Another problem would be to change the compilator since I have the PCWH..actually I don't know if it works with PIC24 series :s.
Do you think it could be difficult to achieve 57600 bps using a one-direction software UART? If yes, buying external UART SC16IS762 would be the best option. Is this device just one UART or more UARTS can be configured? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Thu Oct 06, 2011 7:32 am |
|
|
The software transmit only software is easy and a very good solution as you KNOW when you want to send the data. It's when the PIC has to receive data that software UARTs become tricky. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Thu Oct 06, 2011 12:33 pm |
|
|
There are routines in the Code Library for the SC16IS752 that can easily be modified for the 762.
http://www.ccsinfo.com/forum/viewtopic.php?t=36523 _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Manel28
Joined: 06 May 2010 Posts: 33
|
|
Posted: Tue Oct 25, 2011 3:36 am |
|
|
I've done a software UART transmission by using a 19.2kbps and 56.7kbps baud rate. The first case seems to work pretty well but the data get sometime corrupted when using 56.7kbps. Any answer to this behaviour?. I don't have good sensations with the software UART so I will use the expansor Ttelmah told me . Thanks for the help. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Tue Oct 25, 2011 4:56 am |
|
|
Manel28 wrote: | I've done a software UART transmission by using a 19.2kbps and 56.7kbps baud rate. The first case seems to work pretty well but the data get sometime corrupted when using 56.7kbps. Any answer to this behaviour?. I don't have good sensations with the software UART so I will use the expansor Ttelmah told me . Thanks for the help. |
I have implemented two software UARTS running at 115200 full duplex on a PIC18F4620 at 40MHz running continuously for several years with no apparent data corruption. The trick is using the same baud rate for both SW UARTS, implementing using timers, one for a common transmit bit clock and one each for the receive bit time clocking. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Tue Oct 25, 2011 6:41 am |
|
|
If you want more UARTs, you can always buy cheap little PIC processors and program them to function as UARTs and interface them to your main processor by SPI or whatever you prefer. |
|
|
|