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 support@ccsinfo.com

Confirm SET_UART_SPEED Usage (Multiple UARTS)

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Confirm SET_UART_SPEED Usage (Multiple UARTS)
PostPosted: Tue Oct 28, 2008 1:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 28, 2008 7:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 28, 2008 9:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 28, 2008 9:51 pm     Reply with quote

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.
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