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 support@ccsinfo.com

usart baudrate problems :"Baud rate out of range"

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








usart baudrate problems :"Baud rate out of range"
PostPosted: Wed Jan 18, 2006 1:55 am     Reply with quote

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!?!

Confused Jan
janneb



Joined: 18 Jan 2006
Posts: 3

View user's profile Send private message

usart baudrate problems :"Baud rate out of range"
PostPosted: Wed Jan 18, 2006 2:03 am     Reply with quote

This is just to show, that I am the "guest" that just made the above post...

Wink Jan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 18, 2006 2:40 am     Reply with quote

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



Joined: 18 Jan 2006
Posts: 3

View user's profile Send private message

PostPosted: Wed Jan 18, 2006 3:05 am     Reply with quote

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?

Confused Jan
Ttelmah
Guest







PostPosted: Wed Jan 18, 2006 7:56 am     Reply with quote

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
janneb



Joined: 18 Jan 2006
Posts: 3

View user's profile Send private message

PostPosted: Wed Jan 18, 2006 8:23 am     Reply with quote

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!

Wink KEEP SMILIN' (;>) Jan
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