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.

Question about equation for SPBRG calculation

Status
Not open for further replies.

EgrK

Junior Member level 2
Joined
Jul 31, 2012
Messages
24
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
East part of world
Activity points
1,438
Hi
a project to Send number through serialport, using max232 and pic16f627.
the given are:
High data rate for sendding (BRGH=1)
Asynchronous ( SYNC=0)
Then according to datasheet
https://ww1.microchip.com/downloads/en/DeviceDoc/40300C.pdf
page 69 ,check USART Baud Rate Generator table 12.1 (BAUD RATE FORMULA)
i think we can calculate SPBRG from this equation
Baud Rate= FOSC/(16(X+1)); where x= SPBRG
I am reading a book and the author according to his calculation, he used the equation
Baud Rate= FOSC/(64(X+1)); where x= SPBRG
He obtain value =12 for SPBRG
And the baud rate is 19200, Fosc=4MHz
I have to know why I am mistaken
 
Last edited:

Re: serialport and pic16f627

When BRGH = 0
Use this
Baud Rate= FOSC/(64(X+1)); where x= SPBRG

When BRGH = 1
Use This
Baud Rate= FOSC/(16(X+1)); where x= SPBRG
 

Re: serialport and pic16f627

This is what i have thought.the author must be mistaken.
if you look at book pic project a practical approach by Hassn Parchizadah,
see page 111
he found that SPBRG=12, using this equation Baud Rate= FOSC/(64(X+1)); where x= SPBRG
while using equation ,Baud Rate= FOSC/(16(X+1)); where x= SPBRG , SPBRG=51
8-O
 

Re: serialport and pic16f627

This is what i have thought.the author must be mistaken.
if you look at book pic project a practical approach by Hassn Parchizadah,
see page 111
he found that SPBRG=12, using this equation Baud Rate= FOSC/(64(X+1)); where x= SPBRG
while using equation ,Baud Rate= FOSC/(16(X+1)); where x= SPBRG , SPBRG=51
8-O


Read Datasheet first....
Then any book.. basically books are generic..
 

I am confused ,i have run the given program above
and got 12 ,exactly as the book above. Now i am puzzeled by the datasheet ,it wrote if Asyncronous use
Baud Rate= FOSC/(16(X+1));
DataSheet can not be generic ,any comment ?
 
Last edited:

Why do you say "generic"?

The baud rate generator is simply a programmable divider fed from the system clock and feeding the USART shift register. It is almost identical on all mid-range PICs. FOSC depends on the crystal or RC network you are using and can be anything up to the maximum for the PIC and 'X' the the value you program into the divider.

Do not confuse Synchronous and Asynchronous, they work differently. Async mode uses the formula you showed but in synchronous mode the clock is not generated internally, you have to provide it on one of the pins and it normally comes from the oscillator in the device sourcing data you are reading.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top