View previous topic :: View next topic |
Author |
Message |
Einly
Joined: 10 Sep 2003 Posts: 60
|
Maximum speed of hardware UART |
Posted: Tue Feb 15, 2005 7:52 am |
|
|
I am using PIC16f876. May I know what is the maximum transfer rate of the hardware UART? I am currently using 115kbps, by writing this line:
set_uart_speed(115200)
1) What is the maximum hardware UART speed that I can use?
2) I check the PIC16f876 datasheet and found out that it supports synchronous mode and asynchronous mode. How should I know which mode am I using? The asynchronous mode supports up to 325000 kbps. What is the maximum synchronous speed?
3) Since the maximum of set_uart_speed is 115200, how should I achieve higher speed that 115200? What command line should I write?
Thanks a lot _________________ Einly |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Feb 15, 2005 8:49 am |
|
|
Quote: | 1) What is the maximum hardware UART speed that I can use? | This depends on your clock speed and whether you want synchronous or asynchronous mode. See also the answer to your next question.
Quote: | 2) I check the PIC16f876 datasheet and found out that it supports synchronous mode and asynchronous mode. How should I know which mode am I using? | This depends on your hardware interface. In asynchronous mode the transmitter provides the clock signal to the receiver through an additional wire. Because of the extra costs for this extra wire you won't see this kind of communications very often. RS232 is always synchronous.
Quote: | The asynchronous mode supports up to 325000 kbps. What is the maximum synchronous speed? |
You didn't study the datasheet well enough. Table 10-1 on page 97 gives you the formula for calculating bit rates.
With BRGH set to 1 and running at 20MHz the maximum baudrate = 1250kbaud = 1.250Mbaud. This is also shown in table 10-4 on page 98.
Please be aware that the baudrate generator has some limitations. The baudrate is generated by dividing the clock frequency by a user selectable 8-bits value. When using a clock frequency like 16MHz there is no 8 bit dividing value that will give you an exact baudrate value, only a value that comes close. You are allowed a total baudrate error of 4% for sender and transmitter together. This is the reason you can buy crystals with the odd frequencies like 18.4320MHz because they will give you a 0% baudrate error.
For example running at 20MHz you can't run at 115kbaud because the error margin would be to large. Higher baudrates up to 1250kbaud are possible when choosing outside the range of the default baudrates, make sure to check the receiving device to be capable of handling these odd baudrates. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Feb 15, 2005 9:24 pm |
|
|
Quote: | This depends on your hardware interface. In asynchronous mode the transmitter provides the clock signal to the receiver through an additional wire. Because of the extra costs for this extra wire you won't see this kind of communications very often. RS232 is always synchronous.
|
Asynchronous is the more common (like what a PC would use). Synchronous uses the clock but doesn't require an additional line. The data is half duplex so the Rx pin becomes the data line and the Tx pin becomes the clock.
Einly:
You should really read the data sheet. It explains this pretty well. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Feb 16, 2005 2:03 am |
|
|
Quote: | Synchronous uses the clock but doesn't require an additional line. The data is half duplex so the Rx pin becomes the data line and the Tx pin becomes the clock. | Allright, so I was wrong. No extra line required for synchronous. I never used synchronous and reading this I don't think I ever will.... |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Feb 16, 2005 8:26 am |
|
|
ckielstra wrote: | Quote: | Synchronous uses the clock but doesn't require an additional line. The data is half duplex so the Rx pin becomes the data line and the Tx pin becomes the clock. | Allright, so I was wrong. No extra line required for synchronous. I never used synchronous and reading this I don't think I ever will.... |
Only if you are talking to a device that uses it! |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Thu Feb 17, 2005 5:17 am |
|
|
Quote: | ...For example running at 20MHz you can't run at 115kbaud because the error margin would be to large. |
Can't is too strong. I have lots of PIC based systems devices running at 20MHz reliably communicating at 115K baud. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 17, 2005 6:04 am |
|
|
asmallri wrote: | Quote: | ...For example running at 20MHz you can't run at 115kbaud because the error margin would be to large. |
Can't is too strong. I have lots of PIC based systems devices running at 20MHz reliably communicating at 115K baud. |
Yes. In fact at 20MHz, 115200, is under 1.4% in error (113636.35Hz), which is fine. Conversely, at 4MHz, the original statement would be very true!...
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Feb 17, 2005 7:27 am |
|
|
asmallri wrote: | Quote: | ...For example running at 20MHz you can't run at 115kbaud because the error margin would be to large. |
Can't is too strong. I have lots of PIC based systems devices running at 20MHz reliably communicating at 115K baud. | Sorry. 115kbaud at 20MHz is perfectly possible indeed. Two errors in one thread, it must have been late when I replied to this post.... |
|
|
|