PIC16f1527 UART baudrate formula

Status
Not open for further replies.

ragav4456

Full Member level 4
Joined
Aug 1, 2012
Messages
228
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Visit site
Activity points
2,568
Hi friends

I doubt in PIC uart baudrate formula calculation in Program.

BRGH=1;BRG16=1; kindly send the sample code.

Sample code for PIC16f877A ic UART

Code:
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 */
        }

- - - Updated - - -

how to change this code for pic16f1527 ic?
 

Baudrate formula depends upon this bits BRGH=1; BRG16=1;


BRG16 meaning?
 

I have doubt in 57600 is 16 bit baudrate or 8 bit baudrate.?
 

See this table. What is your Fosc?

For Fosc = 20 MHz, SYNC = 0, BRGH = 1, BRG16 = 1, and baudrate 57600 bps, SPBRG value = 86. So, it is 0086. SPBRGH = 00, SPBRGL = 86.
 

Attachments

  • brg16.jpg
    315.5 KB · Views: 82

SPBRG= 86; means UART not working. what is the reason?
the first post is automatic calculation of SPBRG=X.

UART output is varied. My program starting bit is 35, but output is 82 or 80 and some other else.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…