View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Software UART Questions |
Posted: Tue Aug 28, 2007 2:13 pm |
|
|
3.249
18LF4620
3.3V
Hello All,
I'm having to resort to a software UART to receive for the first time. I had originally planned on a timer/poller receive scheme but haven't had much luck. I just did some searching and reading and I have some questions....
I've mod'd the board to tie RX to B4. I plan to use INT on Change (however, I could use B0-2 for EXT INT if better suited?) What's the better choice?
It appears as though I just put the standard character receive routine in the PortB interrupt? I may have different INTs on other pins, so I'll just qualify which pin is generating the INT and handle it that way.
Is there a good rule about the speed available on a software UART based upon processor speed?
Any other suggestions?
Thanks,
John |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Tue Aug 28, 2007 3:23 pm |
|
|
I think I've found most of what I was looking for:
EXT interrupts are better suited because they allow you to interrupt on only one pin. Using a PortB INT requires that you isolate which pin caused the INT.
Would like to get 14,400 using a 40MHz clock, but it sounds as if that may be iffy.
John |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Aug 28, 2007 4:23 pm |
|
|
Hi John,
In this forum there are examples codes that will be useful for you, search
using the word "STREAM".
Humberto |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Aug 28, 2007 5:09 pm |
|
|
Take time to consider you requirements. Do you really need full-duplex or will half duplex suffice? Is it allowed for the software UART to be blocking or do you need background processing (interrupt driven)?
Half duplex is much easier then full duplex. Interrupt driven code can work in the background but is more difficult than a blocking function.
The CCS compiler generated UART is a blocking half duplex driver.
As a performance reference: My project uses a full duplex interrupt driven 19200 baud software UART routine on a 16MHz PIC18F458. Running at 40MHz this might just be capable of reaching the 56kbaud. It is an assembly routine using high priority interrupts. Sorry, I can't give you the code as it is not my design. I modified the code from the book "Serial PIC'n" version 2.0 by Roger L. Stevens (www.sq-1.com).
Andrew (asmallri) is selling code for several software uarts: http://www.brushelectronics.com/index.php?page=software#SWUART |
|
|
|