View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 04, 2009 2:57 pm |
|
|
Download the PicBaud program. Unzip it and put it on your desktop:
http://www.micromagicsystems.com/#/picbaud/4523812801
(Warning: This web page plays a sound).
Then put in various crystal frequencies and baud rates and see how
much error exists for each combination. Error values for BRGH = 0 and
BRGH = 1 will be given. Just use whichever one is the smallest.
Then consider that the maximum error should be less than 2%
(or better, keep it less than 1%). |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Sun Jan 04, 2009 3:10 pm |
|
|
So when i enter 20Mhz with 2800bps, it says :
BRGH = 0
BAUD : 2790
ERROR : -0.35%
SPBRG : 111
BRGH = 1
BAUD : TOO LOW
ERROR :
SPBRG :
Does it mean i can't use 2800bps ?
I'm new with this notions
For BRGH = 1 i get BAUD = Too low until 7200bps :( |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 04, 2009 3:27 pm |
|
|
Quote: | Does it mean i can't use 2800bps ? |
No. It just won't work for BRGH=1. It works fine for BRGH=0.
The error is only -.035%. It will work well. |
|
|
Ttelmah Guest
|
|
Posted: Sun Jan 04, 2009 3:55 pm |
|
|
Remember also the compiler will automatically select the best combination for you. The point about the program (for CCS users), is that it allows you to test if there _is_ a combination that will work. So long as one combination exists, with an error of a couple of percent or lower, things will be OK.
Try with (for example), a 4MHz crystal, and 115200bps, to find a combination that _won't_ work. The problem is that if the error number goes over about 3%, the serial _will_ be unreliable.
For your crystal, there are few normally used rates that will be problematical, except very _low_ ones. For instance, 50bps won't be doable.
With lower clock rates problems are more common (as with the example already given).
Best Wishes |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Sun Jan 04, 2009 4:28 pm |
|
|
Yeah so much more for me to learn about PICs and CCS
Does it mean CCS will set BRGH automatically, or do i have to set it myself ?
I never set BRGH when using #use rs232 |
|
|
Ttelmah Guest
|
|
Posted: Mon Jan 05, 2009 3:07 am |
|
|
CCS sets it automatically.
Basically it does exactly the arithmetic involved in the picbaud program during compilation, and takes the combination that gives the lowest error, automatically setting the bits for you.
There have in the past been some faults in the selection of the combinations, but for the last year or more, CCS has got it 'right'.
Best Wishes |
|
|
magestik
Joined: 16 Oct 2008 Posts: 59
|
|
Posted: Mon Jan 05, 2009 7:21 am |
|
|
Yeah it works, thank you very much ;) |
|
|
|