![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Guest
|
usart baudrate problems :"Baud rate out of range" |
Posted: Wed Jan 18, 2006 1:55 am |
|
|
I get the above Compiler Error when I use the following for a PIC18F6620:
Code: | ...
#use delay(clock=16000000)
...
#use rs232(baud=256000,xmit=PIN_C6,rcv=PIN_C7,brgh1ok)
...
set_uart_speed(115200); //<===This gives "Baud rate out of range"
... |
I suppose this is "OK", since the Baudrate Error is > 3%
Is it possible to tell the Compiler to accept my requested baudrate and make a successful compilation anyway?
The reason for my question is, that I've "inherited" some code, containing the above lines, which has been compiled and downloaded to a PIC...!
I just can't figure out how this has been done!?!
Jan |
|
![](templates/subSilver/images/spacer.gif) |
janneb
Joined: 18 Jan 2006 Posts: 3
|
usart baudrate problems :"Baud rate out of range" |
Posted: Wed Jan 18, 2006 2:03 am |
|
|
This is just to show, that I am the "guest" that just made the above post...
Jan |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 18, 2006 2:40 am |
|
|
The baud rate calculator that I have, says the error is 3.549%.
If your only goal is to get it to compile, there are a couple ways to do it.
1. You can put in the actual rate that you will get, which is 111111 baud.
Then the compiler will calculate 0% error, and it will compile. Example:
set_uart_speed(111111);
2. You can alter the #use delay() clock value temporarily, so that
the error rate calculated by the compiler is just under 3%.
Then it will compile.
#use delay(clock=16100000)
set_uart_speed(115200);
#use delay(clock=16000000) // Restore correct value.
This answers the narrow question of how to make it compile. |
|
![](templates/subSilver/images/spacer.gif) |
janneb
Joined: 18 Jan 2006 Posts: 3
|
|
Posted: Wed Jan 18, 2006 3:05 am |
|
|
Thanks for your interest, BUT, you misunderstood my question...
I understand that making code changes, can make it compile OK,
BUT how is it possible to get a downloadable .HEX file WITHOUT changes?
How was it possible for the original code writer to compile this code OK???
Is it possible to tell the MPLAB Environment/CCS Compiler to "ignore" the Error and continue compilation?
Jan |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Wed Jan 18, 2006 7:56 am |
|
|
Historically, the margin allowed for baud rate errors, was greater on older versions of CCS. There were then complaints, that the serial often didn't work, so the margin was tightened. This probably explains the successful compilation in the past.
Given that you only want to change the UART speed, simply go DIY, without the checking.
It is not exactly complex, to do a define, that divides the clock rate, by the desired baud rate*4, subtracts one, and loads this into SPBRG. This then won't complain, but will leave you with the risk of unreliable comms.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
janneb
Joined: 18 Jan 2006 Posts: 3
|
|
Posted: Wed Jan 18, 2006 8:23 am |
|
|
Thanks again for yet another workaround...
I know that this code has been compiled recently (last 6 months), but I do NOT know how old the compiler used, was... Maybe it allowed > 3%?
If I use 114600 to be just below 3%, the connection is very unstable (at least when I'm using a portable Toshiba).
I also have gotten a USB->RS232 converter, that allows up to 128000.
Using this setup, gives me a completely "stable" connection...!
Thanks all!
KEEP SMILIN' (;>) Jan |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|