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

Can't achieve 115200 baud on PIC18F2320 at 6MHz

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



Joined: 13 May 2004
Posts: 90
Location: Nashville, TN

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

Can't achieve 115200 baud on PIC18F2320 at 6MHz
PostPosted: Tue Sep 28, 2004 8:42 am     Reply with quote

According to the formula in the 2320's datasheet, I should be able to achieve 115200 baud within <1% error if I run the internal oscillator at 6000000. But when I setup all this machinery,

Code:
#include <18F2320.h>
#device *=16
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP,NOPROTECT,NOCPD,MCLR   
#use delay (clock=6000000)

#use rs232 (baud=115200, xmit=PIN_C6, rcv=PIN_C7, errors, stream=PHONE)         // Using the hardware USART


The compiler tells me that the baud rate is out of range.

Is the compiler wrong, or is the formula wrong?

--
Jeff S.
Ttelmah
Guest







Re: Can't achieve 115200 baud on PIC18F2320 at 6MHz
PostPosted: Tue Sep 28, 2004 9:15 am     Reply with quote

object01 wrote:
According to the formula in the 2320's datasheet, I should be able to achieve 115200 baud within <1% error if I run the internal oscillator at 6000000. But when I setup all this machinery,

Code:
#include <18F2320.h>
#device *=16
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP,NOPROTECT,NOCPD,MCLR   
#use delay (clock=6000000)

#use rs232 (baud=115200, xmit=PIN_C6, rcv=PIN_C7, errors, stream=PHONE)         // Using the hardware USART


The compiler tells me that the baud rate is out of range.

Is the compiler wrong, or is the formula wrong?

--
Jeff S.

I'd redo your calculation!...
The possible prescalers on this chip, are /16, or /64. With 115200, from a 6MHz clock, you want a total division by 6000000/115200 = 52.083. Using the smaller prescaler gives a multiplier of 3, and division by 3*16 = 48 (SPBRG value=2), with the minimum error of 8.5% (52.083/48). This is well out of acceptable limits.
In this case, I'd say the compiler was 'right'.
I think you might be misreading the data sheet, and accidentally using the _synchronous_ divisor value of 4, which would give the close value you are calculating (13*4=52, error = 0.015%). This is not an available divisor for asynchronous comms.

Best Wishes
object01



Joined: 13 May 2004
Posts: 90
Location: Nashville, TN

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

PostPosted: Tue Sep 28, 2004 10:31 am     Reply with quote

Doh!

Thanks. :)

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