|
|
View previous topic :: View next topic |
Author |
Message |
Hampton
Joined: 08 Jun 2006 Posts: 12
|
baud rate out of range |
Posted: Mon Oct 06, 2008 10:35 am |
|
|
I'm using a PIC24FJ64GA004 and using an 8 MHz xtal with 4x PLL to get 32 MHz clock speed. Trying to run a uart at 115.2 kbps. When I compile I get the error "baud rate out of range".
Code: | #use rs232(UART1,baud=115200,parity=N,bits=8) |
If I change the baud rate to 114600 it compiles with no error. Alternatively, if I keep the baud rate at 115200 but change the clock speed to 33 MHz (or anything higher) it compiles with no errors.
Here is my .h file
Code: | #include <24FJ64GA004.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES ICS3 //ICD communication channel 3
#FUSES IOL1WAY //Allows only one reconfiguration of peripheral pins
#FUSES WINDIS //Watch Dog Timer in non-Window mode
#FUSES WPRES128 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES PR_PLL //Primary Oscillator with PLL
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO //OSC2 is general purpose output
#FUSES NOPR //Pimary oscillaotr disabled
#FUSES I2C1SELD
#use delay(clock=32000000)
|
Running PCD 4.079. A colleague tried it in 4.080 and got the same error. Am I doing something wrong here? The PIC running at 32 MHz should be able to handle 115.2 kbps right? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Mon Oct 06, 2008 12:06 pm |
|
|
edited - information irrelevant
Last edited by dyeatman on Mon Oct 06, 2008 1:14 pm; edited 1 time in total |
|
|
Hampton
Joined: 08 Jun 2006 Posts: 12
|
|
Posted: Mon Oct 06, 2008 12:39 pm |
|
|
I got a response back from CCS and they say it's a compiler issue that will be addressed in the next release. |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Fri Feb 20, 2015 6:22 pm |
|
|
Hampton wrote: | I got a response back from CCS and they say it's a compiler issue that will be addressed in the next release. |
Wow I ran into the same problem but with the V5.042 ...
CCS didn't fix it or broke it again?
Quote: | #include <24FJ128GA010.h>
#FUSES XT,PR_PLL,NOPROTECT,NOJTAG,NOWDT,NOCKSFSM
#use delay(clock=32M)
#use rs232(baud=115200,UART1,ERRORS) |
Code: |
*** Error 96 "main.c" Line 4(5,37): Baud rate out of range
*** Error 132 "main.c" Line 45(28,29): STDOUT not defined (may be missing #USE RS232) ::
*** Error 132 "main.c" Line 65(74,75): STDOUT not defined (may be missing #USE RS232) ::
3 Errors, 0 Warnings.
Build Failed.
|
Should I contact CCS?? _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Sat Feb 21, 2015 2:02 am |
|
|
Not the same problem (just looks it!).
In your case, the UART by default uses a baud clock that is 16* the selected rate. This then leads to needing a clock at 1.8432MHz to use 115200baud. The divisions don't allow a clock close enough to this to be generated from 32Mhz, so you get this error.
You need to add the option BRGH1OK to the #use, which allows the BRGH bit to be set to '1', which then allows this to be used, and 4* the baud rate for the baud clock. 460800Hz then needed, which the compiler can get close enough to. |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sat Feb 21, 2015 8:17 am |
|
|
Ttelmah wrote: | Not the same problem (just looks it!).
In your case, the UART by default uses a baud clock that is 16* the selected rate. This then leads to needing a clock at 1.8432MHz to use 115200baud. The divisions don't allow a clock close enough to this to be generated from 32Mhz, so you get this error.
You need to add the option BRGH1OK to the #use, which allows the BRGH bit to be set to '1', which then allows this to be used, and 4* the baud rate for the baud clock. 460800Hz then needed, which the compiler can get close enough to. |
Thanks I completely forget the BRGH1OK.... I thought it was only applicable on older chips having errata / problems with the serial module.
Thanks again! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Sat Feb 21, 2015 1:03 pm |
|
|
Yes, it's one of those very badly documented things.
Because of the chips with faults, CCS defaults to leaving this 'off', even on chip families that don't have the fault. It really ought to default to 'on', and be selectable to off only on chips with problems.
It's particularly a problem on these later chips with the high division ratio when it's off.... |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sat Feb 21, 2015 10:01 pm |
|
|
Ttelmah wrote: | Yes, it's one of those very badly documented things.
Because of the chips with faults, CCS defaults to leaving this 'off', even on chip families that don't have the fault. It really ought to default to 'on', and be selectable to off only on chips with problems.
It's particularly a problem on these later chips with the high division ratio when it's off.... |
Thanks Ttelmah!!!!
_________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Shishido
Joined: 09 Mar 2014 Posts: 10
|
Sorry for jump in |
Posted: Tue Apr 28, 2015 7:47 am |
|
|
Hello, I succeeded compile as below.
Code: |
#include <24FJ128GA010.h>
#FUSES XT,PR_PLL,NOPROTECT,NOJTAG,NOWDT,NOCKSFSM
#use delay(clock=32M)
#PIN_SELECT U1TX = PIN_B5 // UART1 transmit
#PIN_SELECT U1RX = PIN_B6 // UART1 receive
#use rs232(baud=115200,UART1,STREAM=com_1)
main(){
int a=32;
fprintf(com_1,"test=%d ",a);
}
|
But, I am using PIC24FJ128GA010
then, I set 'FRC' to #fuse for RS232C.
ELCouz wrote: | Ttelmah wrote: | Yes, it's one of those very badly documented things.
Because of the chips with faults, CCS defaults to leaving this 'off', even on chip families that don't have the fault. It really ought to default to 'on', and be selectable to off only on chips with problems.
It's particularly a problem on these later chips with the high division ratio when it's off.... |
Thanks Ttelmah!!!!
|
|
|
|
|
|
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
|