+ Post New Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 21
  1. #1
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Microcontroller selection - higher baud rate

    Hi,

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

  2. #2
    Super Moderator
    Points: 264,095, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    46,147
    Helped
    14034 / 14034
    Points
    264,095
    Level
    100

    Re: Microcontroller selection - higher baud rate

    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.



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 80,975, Level: 69
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,421
    Helped
    3728 / 3728
    Points
    80,975
    Level
    69

    Re: Microcontroller selection - higher baud rate

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  4. #4
    Advanced Member level 4
    Points: 8,015, Level: 21
    Achievements:
    7 years registered

    Join Date
    Jan 2015
    Posts
    1,123
    Helped
    350 / 350
    Points
    8,015
    Level
    21

    Re: Microcontroller selection - higher baud rate

    https://www.microchip.com/paramchart...?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



  5. #5
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Re: Microcontroller selection - higher baud rate

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



  6. #6
    Advanced Member level 4
    Points: 8,015, Level: 21
    Achievements:
    7 years registered

    Join Date
    Jan 2015
    Posts
    1,123
    Helped
    350 / 350
    Points
    8,015
    Level
    21

    Re: Microcontroller selection - higher baud rate

    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



  7. #7
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Re: Microcontroller selection - higher baud rate

    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 ?



  8. #8
    Super Moderator
    Points: 80,975, Level: 69
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,421
    Helped
    3728 / 3728
    Points
    80,975
    Level
    69

    Re: Microcontroller selection - higher baud rate

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  9. #9
    Advanced Member level 4
    Points: 8,015, Level: 21
    Achievements:
    7 years registered

    Join Date
    Jan 2015
    Posts
    1,123
    Helped
    350 / 350
    Points
    8,015
    Level
    21

    Re: Microcontroller selection - higher baud rate

    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



    •   AltAdvertisement

        
       

  10. #10
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Re: Microcontroller selection - higher baud rate

    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 ?



    •   AltAdvertisement

        
       

  11. #11
    Super Moderator
    Points: 80,975, Level: 69
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,421
    Helped
    3728 / 3728
    Points
    80,975
    Level
    69

    Re: Microcontroller selection - higher baud rate

    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/calcu...me-factors.php

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  12. #12
    Super Moderator
    Points: 83,016, Level: 70
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,645
    Helped
    4535 / 4535
    Points
    83,016
    Level
    70

    Re: Microcontroller selection - higher baud rate

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  13. #13
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Re: Microcontroller selection - higher baud rate

    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.



  14. #14
    Super Moderator
    Points: 83,016, Level: 70
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,645
    Helped
    4535 / 4535
    Points
    83,016
    Level
    70

    Re: Microcontroller selection - higher baud rate

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  15. #15
    Super Moderator
    Points: 80,975, Level: 69
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,421
    Helped
    3728 / 3728
    Points
    80,975
    Level
    69

    Re: Microcontroller selection - higher baud rate

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  16. #16
    Advanced Member level 4
    Points: 8,015, Level: 21
    Achievements:
    7 years registered

    Join Date
    Jan 2015
    Posts
    1,123
    Helped
    350 / 350
    Points
    8,015
    Level
    21

    Re: Microcontroller selection - higher baud rate

    @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



  17. #17
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Re: Microcontroller selection - higher baud rate

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



  18. #18
    Super Moderator
    Points: 83,016, Level: 70
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,645
    Helped
    4535 / 4535
    Points
    83,016
    Level
    70

    Re: Microcontroller selection - higher baud rate

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  19. #19
    Full Member level 2
    Points: 903, Level: 6

    Join Date
    Nov 2018
    Posts
    138
    Helped
    1 / 1
    Points
    903
    Level
    6

    Re: Microcontroller selection - higher baud rate

    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 ?



    •   AltAdvertisement

        
       

  20. #20
    Super Moderator
    Points: 83,016, Level: 70
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,645
    Helped
    4535 / 4535
    Points
    83,016
    Level
    70

    Re: Microcontroller selection - higher baud rate

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



--[[ ]]--