Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

The config bits settings and oscillator settings for usart in pic18f4550

Status
Not open for further replies.

cyrusdave

Newbie level 4
Joined
Jun 29, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Philippines
Activity points
1,313
..i am new in pic18f4550 programming. i want to use this pic in usart at 115200 baudrate.

i am having a hard time in the config bits settings and oscillator settings.

i really need some help.
 

configure usart 115200 baud

I'm usign this for 9600, just modify it for your needs:

//*** USART CONFIGURATION ***//
SPBRGH = 0; //SPBRGH not used (BAUDCONbits.BRG16 = 0), cleared anyway
SPBRG = 77; //Baud = 9600 with 48 MHz clock speed 0.15% error
TXSTAbits.BRGH = 0; //Low speed Baud Rate configuration
BAUDCONbits.BRG16 = 0; //8 bit Baud Rate Generator
TXSTAbits.SYNC = 0; //Asynchronous mode
RCSTAbits.SPEN = 1; //Serial port enabled
TXSTAbits.TXEN = 1; //Transmit enabled
TRISCbits.TRISC6 = 1; //To configure RC as EUSART
TRISCbits.TRISC7 = 1; //To configure RC as EUSART

Added after 2 minutes:

BTW this is using a 20 MHz xtal, I don't remember if the comments are correct, if somebody else can comment it will be helpful.
 

pic18f4550 48mhz usart

daviddlc said:
I'm usign this for 9600, just modify it for your needs:

//*** USART CONFIGURATION ***//
SPBRGH = 0; //SPBRGH not used (BAUDCONbits.BRG16 = 0), cleared anyway
SPBRG = 77; //Baud = 9600 with 48 MHz clock speed 0.15% error
TXSTAbits.BRGH = 0; //Low speed Baud Rate configuration
BAUDCONbits.BRG16 = 0; //8 bit Baud Rate Generator
TXSTAbits.SYNC = 0; //Asynchronous mode
RCSTAbits.SPEN = 1; //Serial port enabled
TXSTAbits.TXEN = 1; //Transmit enabled
TRISCbits.TRISC6 = 1; //To configure RC as EUSART
TRISCbits.TRISC7 = 1; //To configure RC as EUSART

Added after 2 minutes:
BTW this is using a 20 MHz xtal, I don't remember if the comments are correct, if somebody else can comment it will be helpful.



thanks for the help.. im just bothered about the clocking and the generation of the baudrate.. iwant to have a br of 115200 is it ok for a 48Mhz. i already computed the required crystal for this baud rate it is 29.4912Mhz. do the pic18f4550 support this baud rate? thanks again
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top