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.

rparthiban69

Full Member level 4
Joined
Aug 1, 2012
Messages
225
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Activity points
2,531
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?
 

rparthiban69

Full Member level 4
Joined
Aug 1, 2012
Messages
225
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Activity points
2,531
Baudrate formula depends upon this bits BRGH=1; BRG16=1;


BRG16 meaning?
 

Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0
See the images.
 

Attachments

  • brg16_1.jpg
    brg16_1.jpg
    219.5 KB · Views: 23
  • brg16_2.jpg
    brg16_2.jpg
    323.1 KB · Views: 21

rparthiban69

Full Member level 4
Joined
Aug 1, 2012
Messages
225
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Activity points
2,531
I have doubt in 57600 is 16 bit baudrate or 8 bit baudrate.?
 

Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0
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: 20

rparthiban69

Full Member level 4
Joined
Aug 1, 2012
Messages
225
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Activity points
2,531
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.
 

hemporer

Newbie level 6
Joined
Dec 13, 2012
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
just change associate register.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top