View previous topic :: View next topic |
Author |
Message |
John_Lintern
Joined: 30 Sep 2004 Posts: 14
|
Can't achieve 115200 baud on PIC16C74B at 20MHz |
Posted: Tue May 03, 2005 5:42 am |
|
|
When I try to compile my program using the line...
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
the compiler shows an error saying...
"Baud rate out of range"
Is the PIC16C74B capable of using a baud rate of 115200 ?
If so, how do I calculate the required clock speed to give a baud rate of 115200 ? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue May 03, 2005 6:55 am |
|
|
At 20MHz 115200 baud should be possible.
You didn't mention your compiler version, so I tried it in v3.216 and got the same result ! The program compiles fine for a PIC18F458.
Checking the device options in chipedit.exe I noticed an option being set saying "BRGH can not be 1", disabling this option makes the program compile .
If you don't have chipedit.exe you can set the registers manually:
SPBRG = 0x0A
TXSTA = 0x26
RCSTA = 0x90
Does anyone know why BRGH is disabled? According to the datasheets it is a valid bitsetting and it isn't mentioned in the errata sheets as well. |
|
|
Charlie U
Joined: 09 Sep 2003 Posts: 183 Location: Somewhere under water in the Great Lakes
|
|
Posted: Tue May 03, 2005 8:00 am |
|
|
Take a look at the errata sheet for the PIC16C74. There is a high error rate when the BRGH is set, and they recommend that it be set low. In the early days, this was included in the errata for the rev A version at least and possibly the Rev B, I don't recall now. There is a parameter that can be included in the #use RS232 pre-processor command that allows the BRGH to be set which is BRGH1OK. The second to last character is the letter O not the number 0.
So just add it to the command like so:
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, BRGH1OK)
and it should work.
You can also go into the device editor, if you are using PCW, and modify the part definition by removing the check in the box for this errata. This will allow the bit to be set high. |
|
|
|