|
|
View previous topic :: View next topic |
Author |
Message |
JamesH Guest
|
Baud rate out of range error. |
Posted: Mon Dec 09, 2002 12:59 pm |
|
|
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. |
Posted: Mon Dec 09, 2002 1:36 pm |
|
|
:=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. |
Posted: Mon Dec 09, 2002 2:20 pm |
|
|
:=:=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. |
Posted: Mon Dec 09, 2002 2:37 pm |
|
|
:=:=:=#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. |
Posted: Mon Dec 09, 2002 2:46 pm |
|
|
:=:=:=:=#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 |
|
|
|
|
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
|