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 CCS Technical Support

Baud rate out of range error.

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







Baud rate out of range error.
PostPosted: Mon Dec 09, 2002 12:59 pm     Reply with quote

Hello,

I am attempting to create a simple program for the PIC 16F627
microcontroller. However, when I compile the program, I get a "Baud rate out of range" error.

I have gone to the Microchip web site and found a manual on the PIC16F62X series of microcontrollers (document number DS40300B). Page 75 of the manual states that a clock rate of 3.579 MHz will result in a -2.90\% error for a baud rate of 57600. This error percentage is within the 3\% tolerance that your compiler requires.

Why won't the apparently valid clock speed of 3579000 and baud rate of 57600 compile (see code snippet below)?

Thanks,
James.

#include <16F627.h>
#use delay(clock=3579000,RESTART_WDT)
#fuses XT,WDT,MCLR
#define TRESET 44
#define TMISO 45
#define TMOSI 46
#define TCLK 47
#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_A3,rcv=PIN_A2)
___________________________
This message was ported from CCS's old forum
Original Post ID: 9897
R.J.Hamlett
Guest







Re: Baud rate out of range error.
PostPosted: Mon Dec 09, 2002 1:36 pm     Reply with quote

:=Hello,
:=
:=I am attempting to create a simple program for the PIC 16F627
:=microcontroller. However, when I compile the program, I get a "Baud rate out of range" error.
:=
:=I have gone to the Microchip web site and found a manual on the PIC16F62X series of microcontrollers (document number DS40300B). Page 75 of the manual states that a clock rate of 3.579 MHz will result in a -2.90\% error for a baud rate of 57600. This error percentage is within the 3\% tolerance that your compiler requires.
:=
:=Why won't the apparently valid clock speed of 3579000 and baud rate of 57600 compile (see code snippet below)?
:=
:=Thanks,
:=James.
:=
:=#include <16F627.h>
:=#use delay(clock=3579000,RESTART_WDT)
:=#fuses XT,WDT,MCLR
:=#define TRESET 44
:=#define TMISO 45
:=#define TMOSI 46
:=#define TCLK 47
:=#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_A3,rcv=PIN_A2)

Er. Because you are asking the chip to use the software UART, not the hardware UART!... The pins for the hardware UART on the 16F62x family, are pins B1, and B2, not A2, and A3...
The software UART cannot handle this high speed on a chip at this sort of clock rate.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 9903
JamesH
Guest







Re: Baud rate out of range error.
PostPosted: Mon Dec 09, 2002 2:20 pm     Reply with quote

:=:=Hello,
:=:=
:=:=I am attempting to create a simple program for the PIC 16F627
:=:=microcontroller. However, when I compile the program, I get a "Baud rate out of range" error.
:=:=
:=:=I have gone to the Microchip web site and found a manual on the PIC16F62X series of microcontrollers (document number DS40300B). Page 75 of the manual states that a clock rate of 3.579 MHz will result in a -2.90\% error for a baud rate of 57600. This error percentage is within the 3\% tolerance that your compiler requires.
:=:=
:=:=Why won't the apparently valid clock speed of 3579000 and baud rate of 57600 compile (see code snippet below)?
:=:=
:=:=Thanks,
:=:=James.
:=:=
:=:=#include <16F627.h>
:=:=#use delay(clock=3579000,RESTART_WDT)
:=:=#fuses XT,WDT,MCLR
:=:=#define TRESET 44
:=:=#define TMISO 45
:=:=#define TMOSI 46
:=:=#define TCLK 47
:=:=#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_A3,rcv=PIN_A2)
:=
:=Er. Because you are asking the chip to use the software UART, not the hardware UART!... The pins for the hardware UART on the 16F62x family, are pins B1, and B2, not A2, and A3...
:=The software UART cannot handle this high speed on a chip at this sort of clock rate.
:=
:=Best Wishes

I have tried compiling with xmit=B1 and recv=B2 and vice versa and I still get the baud rate out of range error for baud 57600 (note that I get no error for baud 38400).

Any suggestions?
___________________________
This message was ported from CCS's old forum
Original Post ID: 9908
Laurent chouinard
Guest







Re: Baud rate out of range error.
PostPosted: Mon Dec 09, 2002 2:37 pm     Reply with quote

:=:=:=#include <16F627.h>
:=:=:=#use delay(clock=3579000,RESTART_WDT)
:=:=:=#fuses XT,WDT,MCLR
:=:=:=#define TRESET 44
:=:=:=#define TMISO 45
:=:=:=#define TMOSI 46
:=:=:=#define TCLK 47
:=:=:=#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_A3,rcv=PIN_A2)
:=:=
:=I have tried compiling with xmit=B1 and recv=B2 and vice versa and I still get the baud rate out of range error for baud 57600 (note that I get no error for baud 38400).
:=
:=Any suggestions?

Yes, try the vice-versa. That is:
#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_B2,rcv=PIN_B1)

it's extremely important that you use PIN_B2 for xmit, and PIN_B1 for receive. This is the only way that the chip can use the hardware USART, and only the hardware USART can handle your baudrate with your clock speed.

I've just tried your code with the #use rs232 i wrote above and it compiles fine.

Regards.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9909
JamesH
Guest







Re: Baud rate out of range error.
PostPosted: Mon Dec 09, 2002 2:46 pm     Reply with quote

:=:=:=:=#include <16F627.h>
:=:=:=:=#use delay(clock=3579000,RESTART_WDT)
:=:=:=:=#fuses XT,WDT,MCLR
:=:=:=:=#define TRESET 44
:=:=:=:=#define TMISO 45
:=:=:=:=#define TMOSI 46
:=:=:=:=#define TCLK 47
:=:=:=:=#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_A3,rcv=PIN_A2)
:=:=:=
:=:=I have tried compiling with xmit=B1 and recv=B2 and vice versa and I still get the baud rate out of range error for baud 57600 (note that I get no error for baud 38400).
:=:=
:=:=Any suggestions?
:=
:=Yes, try the vice-versa. That is:
:=#use rs232(BRGH1OK,baud=57600,parity=N,xmit=PIN_B2,rcv=PIN_B1)
:=
:=it's extremely important that you use PIN_B2 for xmit, and PIN_B1 for receive. This is the only way that the chip can use the hardware USART, and only the hardware USART can handle your baudrate with your clock speed.
:=
:=I've just tried your code with the #use rs232 i wrote above and it compiles fine.
:=
:=Regards.

I just got off the phone with CCS tech support. They too could compile my code snippet (after correcting the pin assignments). They could not suggest why I cannot compile on my side. Since I am running version 3.002 of the compiler, I will get the latest version and try again. BTW, my installation does not understand the set_uart_speed function--so myabe there is something wrong with my installation.

Thanks for all the help,
James.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9911
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