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.

PIC16f1527 UART baudrate formula

Status
Not open for further replies.

ragav4456

Full Member level 4
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?
 

See the images.
 

Attachments

  • brg16_1.jpg
    brg16_1.jpg
    219.5 KB · Views: 74
  • brg16_2.jpg
    brg16_2.jpg
    323.1 KB · Views: 78

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top