|
|
View previous topic :: View next topic |
Author |
Message |
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
Can't achieve 115200 baud on PIC18F2320 at 6MHz |
Posted: Tue Sep 28, 2004 8:42 am |
|
|
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 |
Posted: Tue Sep 28, 2004 9:15 am |
|
|
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
|
|
Posted: Tue Sep 28, 2004 10:31 am |
|
|
Doh!
Thanks. :)
--
Jeff S. |
|
|
|
|
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
|