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.

Microcontroller selection - higher baud rate

Status
Not open for further replies.

engr_joni_ee

Advanced Member level 3
Joined
Nov 3, 2018
Messages
718
Helped
2
Reputation
4
Reaction score
4
Trophy points
18
Activity points
5,940
Hi,

I am looking for Microcontroller by Microchip that support higher baud rate like 115 k or higher with internal oscillator. Any suggestion ?
 

You might look for newer 18FxxKyy series that can achieve 64 MHz clock with internal oscillator and PLL. They support 115k or even higher baud rates. Please consider that internal oscillator has limited accuracy and temperature drift, it can be also detuned by applying mechanical force to the PCB.
 

Hi,

I assume every PIC and AVR microcontroller can go higher than 115200 baud.
Just review the datasheets.
For sure it depends on the microcontroller's system clock frequency.

Klaus
 

https://www.microchip.com/paramchartsearch/chart.aspx?branchID=1005
Select the options that are important to you and then select the MCU that you want.
As a general rule, the clock used for UARTs need to be within ~2% to be reliable (also assuming a 16x sampling). Check very carefully that the internal clock is rated to that level of accuracy/stability.
Certainly the older MCUs should NOT be used without an external oscillator but some of the newer ones have better internal clock designs that might fit your purpose.
Susan
 

I was checking once PIC18F2550 which I guess does not support 115k Baud rate with internal oscillator.
 

Personally I would not use the internal oscillator for the UART (regardless of BAUD rate) with that (relatively) old chip. Depending on the temperature range and voltage, you can get +/- 10% between the max and min frequencies. Even at ideal temperature and voltage, the data sheet says between +/-2% and typical of +/-1%.
While that looks like it is within the +/-2% I mentioned above, don't forget that the accuracy applies to BOTH ends of the communication line. If the device you are communicating with is absolutely accurate all the time then you need only consider the accuracy of your device. But any variation in the other device must be added to the variation in your - the PIC18F2550 can range over the full tolerance range itself so it can be quite easy for errors to be introduced.
Why not just add a crystal (and a couple of capacitors) and know that it will work?
Susan
 

Hi Susan,

Thanks for your comment. I am also thinking to use external crystal to have more stable UART. I have 16 MHz and 20 MHz in stock. Any 18F PIC with 16 MHz or 20 MHz crystal recommended for 115k Baud or higher ?
 

Hi,

If you use (non UART standard) XTALs, then it's almost independent of microcontroller (as long as they don't include a PLL).
Because the usual way to generate baude rate is to integer divide the XTAL clock frequency.
Thus the frequency error is the same with all the microcontrollers.

Klaus
 

See the link in my reply #4, select the PIC18 MCUs under the '8 bit Microcontrollers' item on the left and make your choice - probably based on whatever else you want the MCU to do.
If you want to use a crystal then pick any.
If you want to use an internal oscillator, then I'd go for any of the ones with a K (or possibly a Q) in the part number and certainly ones with the OSCTUNE (or equivalently named) register as that will be the best (and recommended by Microchip) way to tune the oscillator to be within the required accuracy.
Susan
 

I guess with in Microcontroller with PLL it is possible to multiply the frequency by factor like 2 and 4 etc. and in Microcontroller XTAL connected externally we can divide the frequency by integer for BUAD, right ?
 

Hi,

There are XTAL frequencies for UART operation, like 3.6864MHz or 7.3728MHz

You can't generate them by PLL "multiply with 2 or 4" from a 8MHz XTAL frequency.

The mathematical solution is:
The standard baud rates are:
* 9600 = 2 × 2 × 2 × 2 × 2 × 2 × 2 × 3 × 5 × 5 (divided by prime numbers)
* 19200 = 2 × 9600 = 2 × ( 2 × 2 × 2 × 2 × 2 × 2 × 2 × 3 × 5 × 5 )
...
* 115200 = 12 × 9600 = 2 × 2 × 3 × ( 2 × 2 × 2 × 2 × 2 × 2 × 2 × 3 × 5 × 5 )

If you want to use a 8MHz XTAL on 115200baud:
* 8M = 8.000.000 = 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 5 × 5 × 5 × 5 × 5 × 5

Equal prime numbers for both frequencues are:
2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 5 × 5
Divide the frequency be the equal numbers:

* 115200 / (2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 5 × 5 ) = 3 × 3
* 8M / (2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 × 5 × 5 ) = 5 × 5 × 5 × 5

The problem now is the missing "3 × 3" that the 8M does not include, but the 115200 does.

So the PLL solution is to multiply the XTAL frequency by the missing (3 × 3 ) = 9
Then you are able to generate all baud rates perfectly.

Link for prime factorisation: https://www.calculatorsoup.com/calculators/math/prime-factors.php

Klaus
 

Another point worth mentioning is the PIC range have Baud rate generators that can hold any 8 or in some cases 16 bit number. They are not confined to the industry standard rates from common clock frequencies. Although for 115,200 bauds the divisor (BRG value) will be low, you can set it to any value and use an appropriate clock frequency to produce almost any baud rate you want.

Brian.
 

I am sorry I don't get the calculations. Kindly explain it with an other example. I have 16 MHz and 20 MHz XTAL crystals. I need to find and buy 18F PIC Microcontroller which can work for 115 K and higher baud rates.
 

The baud rate is set by dividing the clock (your XTAL) by either 4 or 16 then by dividing again by the number in the baud rate divider register. It is a simple frequency divider.

You haven't said what baud rate you want, both ends of your serial link must use the same speed but that speed can be as fast or slow as the PIC will allow. Tell us what you mean by 'higher baud rate' , is is 115,201 bauds or something much faster? The formula for calculating the speed, based on the clock and divisor ratios is in every PIC data sheet. You are not constrained to using the values in the example tables in the data sheet, each different value in the divider register will produce a different baud rate.

Brian.
 

Hi.

I am sorry I don't get the calculations. Kindly explain it with an other example. I have 16 MHz and 20 MHz XTAL crystals. I need to find and buy 18F PIC Microcontroller which can work for 115 K and higher baud rates.
The math says that you need an XTAL frequency which is an integer multiple of 9.
Neither 16MHz is, nor 20MHz is. --> impossible

Klaus
 

@KlausST - the '...integer multiple of 9' part is true but not necessarily relevant depending on the actual device the OP chooses.
As @betwixt points out, most (if not all) of the PIC18F series of MCUs have a 'Baud Rate Generator' that is a divide-by-N that is 8 or 16 bits wide. Therefore divide by 9, or any other number between 1 and 255 (or 65535) - especially multiples of 9 - is entirely possible.
Given a 20MHz crystal (which is Fosc), a Baud rate of 115,200 and using the 16-bit divider and the BRGH bit set, then the required division number is Fosc/(4 * 115200)-1 = 20,000,000/460800 - 1 = 42.4 which is rounded down to 42. When you then use that to calculate the actual Baud rate, you get Fosc/(4*(n+1)) = 20,000,000/(4 * 43) = 116,279.07 which is .94% high which is within the normal tolerances for a UART. (I used the PIC18F4550 for this example but the formulae are almost identical for all of the PIC18F series.)
@joniengr - you keep saying '115,200 or higher' but this is probably the wrong way to go about your design. The questions you should be asking are: 1) how much data do I have to transfer and how fast - that will tell you the minimum Baud rate; then 2) what is the maximum Baud rate that the other device can handle - that will tell you the maximum Baud rate of the transfer. So long as the maximum is more than the minimum Baud rate then you can select whatever rate you need. It is usual to select one of the standard Baud rates but if both devices can handle non-standard rates then you can use whatever you want.
Of course there are all sorts of other considerations in a design such as how fast the devices at each end can generate/process the information begin transferred but we don't have any information on that so that part is up to you.
I must admit, you seem to be struggling with this and that makes me think that you need to stop and learn a bit more about microcontrollers before you go any further. This is all very basic stuff and once you understand it, then you can progress on.
Susan
 

@Aussie - 256000 bits per second Baud rate is actually required.
 

The best you can manage with a PIC18F is to set BRGH =1, SPBRG = 20 and use a clock of 21.5MHz, that gives a baud rate of 255,952, an error of 0.02%.
With a 20MHz clock, your limit is 250K bauds.

Brian.
 

I guess the formula for calculating the baud rates are below.

SPBRG = (Fosc / (16 x Baud rate)) - 1, BRGH = 1 High Speed
SPBRG = (Fosc / (64 x Baud rate)) - 1, BRGH = 0 Low Speed

With BRGH = 1 which is high speed, and Fosc = 12 MHz, I get 115384 which is 2% error compared to 115200. This gives value 25 for SPBRG register.
Question is it possible to get Fosc = 12 MHz from XTAL 16 MHz or 20 MHz ?
 

I guess the formula for calculating the baud rates are below.

SPBRG = (Fosc / (16 x Baud rate)) - 1, BRGH = 1 High Speed
SPBRG = (Fosc / (64 x Baud rate)) - 1, BRGH = 0 Low Speed
Congratulations for reading the data sheet.


Question is it possible to get Fosc = 12 MHz from XTAL 16 MHz or 20 MHz ?
But time to go back and read it again.


Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top