+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Full Member level 2
    Points: 777, Level: 6

    Join Date
    Nov 2018
    Posts
    121
    Helped
    1 / 1
    Points
    777
    Level
    6

    Baud rate limitation in PIC Microcontoller

    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 ?

  2. #2
    Super Moderator
    Points: 79,217, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,080
    Helped
    3642 / 3642
    Points
    79,217
    Level
    68

    Re: Baud rate limitation in PIC Microcontoller

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



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 262,035, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,804
    Helped
    13925 / 13925
    Points
    262,035
    Level
    100

    Re: Baud rate limitation in PIC Microcontoller

    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



    •   AltAdvertisement

        
       

  4. #4
    Full Member level 2
    Points: 777, Level: 6

    Join Date
    Nov 2018
    Posts
    121
    Helped
    1 / 1
    Points
    777
    Level
    6

    Re: Baud rate limitation in PIC Microcontoller

    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.

    Click image for larger version. 

Name:	Untitled.png 
Views:	4 
Size:	131.4 KB 
ID:	156513

    Click image for larger version. 

Name:	Untitled 01.png 
Views:	1 
Size:	120.3 KB 
ID:	156514



    •   AltAdvertisement

        
       

  5. #5
    Super Moderator
    Points: 262,035, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,804
    Helped
    13925 / 13925
    Points
    262,035
    Level
    100

    Re: Baud rate limitation in PIC Microcontoller

    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.



  6. #6
    Super Moderator
    Points: 79,217, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    16,080
    Helped
    3642 / 3642
    Points
    79,217
    Level
    68

    Re: Baud rate limitation in PIC Microcontoller

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



  7. #7
    Super Moderator
    Points: 82,037, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,457
    Helped
    4488 / 4488
    Points
    82,037
    Level
    69

    Re: Baud rate limitation in PIC Microcontoller

    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.
    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.



  8. #8
    Full Member level 2
    Points: 777, Level: 6

    Join Date
    Nov 2018
    Posts
    121
    Helped
    1 / 1
    Points
    777
    Level
    6

    Re: Baud rate limitation in PIC Microcontoller

    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 ?



    •   AltAdvertisement

        
       

  9. #9
    Super Moderator
    Points: 82,037, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,457
    Helped
    4488 / 4488
    Points
    82,037
    Level
    69

    Re: Baud rate limitation in PIC Microcontoller

    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.
    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.


    1 members found this post helpful.

  10. #10
    Full Member level 4
    Points: 3,162, Level: 13
    Achievements:
    7 years registered

    Join Date
    Nov 2009
    Location
    United States
    Posts
    238
    Helped
    68 / 68
    Points
    3,162
    Level
    13

    Re: Baud rate limitation in PIC Microcontoller

    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.



--[[ ]]--