View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Confirm SET_UART_SPEED Usage (Multiple UARTS) |
Posted: Tue Oct 28, 2008 1:14 pm |
|
|
Hello All,
I'm using a 6627 w/ 2 hardware UARTS and want to make sure I'm using this function properly:
Code: |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=CAMERA) // camera
#use rs232(baud=115200,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=XBEE,errors) // xbee
SET_UART_SPEED(57600,XBEE) |
The compiler uses the stream to determine which UART to apply the change to?
Thanks,
John
EDIT:
And is there any need to delay before using the UART after changing the speed? |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Tue Oct 28, 2008 7:53 pm |
|
|
Well I'm up against another question. Compiling I get a "BAUD RATE OUT OF RANGE" error with 1200.
v3.49 (I think, not sure how to get it out of the command line compiler...)
18F6627 @ 40MHz
From reading some, it looks like a compiler problem and I can get by using this:
Code: | #byte BAUDCON=0xFB8
#byte TXSTA=0xFAC
#bit BRGH=TXSTA.2
#bit BRG16=BAUDCON.3
int16 SPBRG;
#locate SPBRG=0xFAF
void set_baud(int32 speed) {
int16 divisor;
//Switch to 16bit mode
BRGH=0;
BRG16=1;
//calculate required divisor - needs 'CLOCK_RATE' defined as
//operating frequency.
divisor=(CLOCK_RATE/(speed*16))-1;
SPBRG=divisor;
} |
Courtesy of Ttelmah.
Just need to throw 40000000 into CLOCK_RATE?
Thanks again,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 28, 2008 9:17 pm |
|
|
Quote: |
v3.49 (I think, not sure how to get it out of the command line compiler...) |
Look at the top of the .LST file after a successful compilation. The .LST
file will be in your project directory.[/quote] |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Tue Oct 28, 2008 9:51 pm |
|
|
3.236
Thanks. I've been out of this for a while and have been slow picking things up again.
Looks like it only did barfed on the 1200. Anything > 1200 it didn't have problem with. |
|
|
|