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

Maximum speed of hardware UART

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



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

Maximum speed of hardware UART
PostPosted: Tue Feb 15, 2005 7:52 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 15, 2005 8:49 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 15, 2005 9:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 16, 2005 2:03 am     Reply with quote

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.... Cool
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 16, 2005 8:26 am     Reply with quote

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.... Cool


Only if you are talking to a device that uses it!
asmallri



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

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

PostPosted: Thu Feb 17, 2005 5:17 am     Reply with quote

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







PostPosted: Thu Feb 17, 2005 6:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 17, 2005 7:27 am     Reply with quote

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....
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