- This topic has 0 replies, 1 voice, and was last updated 12 years, 4 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
|
Microcontroller › PIC › PIC16f1527 UART1 selection
PIC16f1527
FOSC-20mhz,baudrate-57600,Hi tech c compiler
I have doubt,how to configure UART1 selection and UART1 configuration bits, baudxcon bits.
Baudrate formula calculation in c program
int X;
/* calculate and set baud rate register */
/* for asynchronous mode */
tmp = 16UL * baud;
X = (int)(FOSC/tmp) - 1;
if((X>255) || (X<0))
{
tmp = 64UL * baud;
X = (int)(FOSC/tmp) - 1;
if((X>255) || (X<0))
{
return 1; /* panic - baud rate unobtainable */
}
else
BRGH=0; /* low baud rate */
}