#1956 EUSART wrong baudrate when using SPBGRH


I finally found why I never succeeded to get the right baudrate when using the usart library.
When you want to use SPBRG and SPBGRH for baudrate generation, you have to set TXSTAbits.BRGH but you have also to set BAUDCONbits.BRG16.
Here is a patch that fixes the bug for pic18f4550.
I don't know if all MCU that brings TXSTAbits.BRGH bring also BAUDCONbits.BRG16.


  • Alain Portal

    Alain Portal - 2012-02-29

    Fix high speed baudrate generation

  • Alain Portal

    Alain Portal - 2012-02-29

    In that patch I removed instruction "TXSTAbits.BRGH = 0;" because TXSTA is cleared at the begining of the function.

  • Raphael Neider

    Raphael Neider - 2012-03-10

    Accepted in r7424.

    (Of course, 18f[24][45][28] and several other MCUs do have BRGH, but lack BRG16, which required some further modifications.)

  • Raphael Neider

    Raphael Neider - 2012-03-10
    • milestone: --> fixed
    • assigned_to: nobody --> tecodev
    • status: open --> closed-accepted

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks