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.

Baud rate limitation in PIC Microcontoller

Status
Not open for further replies.

engr_joni_ee

Advanced Member level 3
Advanced Member level 3
Joined
Nov 3, 2018
Messages
820
Helped
2
Reputation
4
Reaction score
7
Trophy points
18
Activity points
6,850
Hi,

I have tested PIC 16F876 with 57600 which works fine. However it fails at 115200. Is this a limit ? Is it possible to use 16F876 with 115200 ?
 

Hi,

the datasheet should tell you the limitations.

I doubt that a PIC generally has a baud rate limiting around 100kBaud.

I rather assume it is a problem of
* Clock frequency (absolute, nominal value)
* clock frequency accuracy
* baud rate divider setting

But all this should be well explained in the datasheet, the application notes provided by Microchip or any PIC_UART tutorial.

Klaus
 

Please review the datasheet, particularly chapter 10.1 USART Baud Rate Generator. You'll see that it's not feasible with standard crystal frequencies, but well possible with "UART" crystals like 14.74 MHz. You can even implement up to 921 kBaud
 

I don't find 14.74 MHz and 921 kBaud in the chapter 10.1 of datasheet 16F876.

I was using internal oscillator which limit me to 57600 baud rate.

With 16 MHz X-TAL crystal it is possible to achieve higher baud rate for example 115200 ?

I have attached baud rate table. I don't understand what is High and Low in baud rate column.

Untitled.png

Untitled 01.png
 

The table is only giving examples for certain crystal frequencies, for other frequencies use the given formula.

16 MHz is one of the "standard" crystal frequencies that can't generate 115 kBaud.

I was using internal oscillator which limit me to 57600 baud rate.
According to the datasheet PIC16F876 has no internal high speed oscillator as provided by other PIC devices. Not sure which configuration you are referring to.
 

Hi,

I don't find 14.74 MHz
For sure the datasheet can´t give a table for every possible XTAL frequency. (It surely has enough pages yet. )
But you are able to use the given formulas.
Or just recognize that 14.74(56)MHz is 4 x 3.6864MHz --> thus use the table of 3.6864MHz and multiply/divide the values by 4

I was using internal oscillator which limit me to 57600 baud rate.
The limit depends on the chosen oscillator frequency. .. but you hide this information.

Are you sure you have read the MICROCHIP application note about PICmicro and USART....

With 16 MHz X-TAL crystal it is possible to achieve higher baud rate for example 115200 ?
The table includes f_osc = 16MHz ... so go through the table and the datasheet chapter.

I don't understand what is High and Low in baud rate column.
Simply the lowest and highest possible baud rate setup, ignoring any baud rate errors.

Klaus
 

The maximum Bauds rate is determined entirely by the clock frequency.
The rated maximum clock frequency is 20MHz, if pushed beyond that it might still work, and the Baud rate may be higher, but outside of design specification you are in uncharted territory.
Bit rate in high speed mode is Fosc/(16*(1+x)) where '1+x' is an 8-bit value in the SPBRG register. So with x=0 the maximum rated speed is 20,000,000/(16*1) = 1,250,000 Bauds.

Brian.
 

This means that the nearest baud rate to 115200 with 16 MHz crystal in PIC16F876 is 16,000,000/(16*(1+7)) = 125,000, right ? where SPBRG register has to be written with 7.

This can also be achieved with 8 MHz oscillator internal 8,000,000/(16*(1+3)) = 125,000, where SPBRG register has to be set at 3.

It is possible to get more closer to 115200 ?
 

Your calculations are correct and you can't get closer while using a 16MHz clock. It might just work, the error is about 2% which is the 'rule of thumb' limit for serial speeds. The internal sampling rate allows for slight speed differences. If you need closer speeds your only option is to use a different clock speed or to use a different PIC, for example a PIC18 which has a 16-bit baud rate divisor to allow finer selection.

I would recommend you change your clock to 18.432MHz if possible, the software will run a little faster but you can get the exact Bauds rate you want and it is easier to get common delays from the timers too. 18.432MHz is a common and cheap crystal frequency.

Brian.
 
I agree with the previous posters, and you really should strive to use common industry use baud rates that your device can support with < 2% error for maximum compatibility.
Keeping this error at or less than 2% enables you to easily use common PC software, etc at standard settings to communicate to your device without framing errors or other UART faults.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top