View previous topic :: View next topic |
Author |
Message |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
Maximum USART speed possibel with 4Mhz Xtal |
Posted: Sat Jul 31, 2004 11:48 pm |
|
|
Hello,
I am using PIC 16F877 and the CCS compiler. I as wondering what would be the maximum Baud rate possible with a 4 MHz xtal.
thanks
arun |
|
|
Guest
|
|
Posted: Sun Aug 01, 2004 2:04 am |
|
|
With BRGHOK it is
4000000/16=250kbaud
Normally it is
4000000/64 = 62500
Keep in mind that the baud rate is calculated as either
Fosc/16/(N+1) or
Fosc/64/(N+1) where N is the baud rate generator division factor. So you can not use most of standard baud rates @4MHz. Use a baud rate crystal instead. |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Sun Aug 01, 2004 6:39 am |
|
|
Hello,
I calculated that the baud rate cannot be more than 19200. Which means if I want higher baud rates I must go in for a 20 Mhz crystal.
What is a baud rate crystal and how can I connect it to the PIC.
Just curious to know, I am using a PCB with parts that have been soldered manually ( the maximum track spacing on the PCB is 0.5 mm) , is it OK to use a 20 Mhz crystal or will it cause problems ??. 1
thanks
arun |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Aug 01, 2004 7:10 am |
|
|
Quote: | I calculated that the baud rate cannot be more than 19200. Which means if I want higher baud rates I must go in for a 20 Mhz crystal. |
Your calculations must be wrong. Even without calculations you can check Table 10-3 and 10-3 of the PIC16F877 datasheet where settings for several baudrates and crystals are shown: For a 4MHz crystal it states that the maximum baudrate with BRGH=0 is 62500 baud and with BRGH=1 even 250.000 baud.
Quote: | What is a baud rate crystal and how can I connect it to the PIC. |
These are normal crystals with very odd looking frequencies like 3.6864MHz. They are usefull in baudrate generators because dividing this frequency by a power of 2 will give you an exact baudrate value.
Just remember that in specifying the baudrate you are only allowed a maximum error of 3%. For example, trying to create a baudrate of 19k2 with a 4MHz crystal with BRGH=0 requires you to set SPBRG=2 (See table 10-3). The actual baudrate generated will be 20.833baud, being an error of 8.51%!!! This is to large an error. Same settings with a 3.6864MHz crystal give a 0% error. |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Mon Aug 02, 2004 7:30 am |
|
|
Yes you are right my calculations are wrong !!! Silly of me
Thank you very much
cheers
arun |
|
|
|