• AVR Freaks

Hot!PIC32MZ UART Errata solution

Author
ryanjones
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2019/01/07 13:51:21
  • Location: 0
  • Status: offline
2019/11/11 17:42:59 (permalink)
0

PIC32MZ UART Errata solution

Hi
 
Currently using a PIC32MZ2064DAR176 to send and receive some data to a ublox u201 modem.
Have figured out that the pic was sending malformed stop bits to the modem which was causing the auto-baud rate to not work correctly. In the errata for this chip, in section 2.18.1 it says that to use the UART in high speed mode I have to recalculate the BRG register value. I have done that and set the value but the stop bit is still shorter than the other bits that get sent to the modem, and the modem doesn't respond to it.
 
Attached is an image of a capture of the serial comms. You can see that the stop bit is shorter than the other one.
I was able to get the modem responding by setting the UART to have two stop bits instead of one, but this doesn't seem to work when getting the response back from the modem, it doesn't match what's on the wire.
 
Does anyone have any ideas on how to fix the errata on this chip and have a single stop bit for the UART. Am I doing my calculation wrong.
Using the formula BRG = ( PbClk / 16 * BaudRate ) - 1 to calculate it.
 
Thanks,
Ryan

Attached Image(s)

#1

3 Replies Related Threads

    jg_ee
    Super Member
    • Total Posts : 175
    • Reward points : 0
    • Joined: 2015/04/30 10:54:52
    • Location: Colorado
    • Status: offline
    Re: PIC32MZ UART Errata solution 2019/11/12 09:21:36 (permalink)
    0
    Can you share your UART init code?  According to the errata this should not be present if you are operating in standard speed mode BRGH=0, which I have to assume you are based on the formula that your shared.
     
    Are you getting the baud rate you are calculating at least?
    #2
    jg_ee
    Super Member
    • Total Posts : 175
    • Reward points : 0
    • Joined: 2015/04/30 10:54:52
    • Location: Colorado
    • Status: offline
    Re: PIC32MZ UART Errata solution 2019/11/12 09:23:44 (permalink)
    0
    Also glancing at the ublox 201 quick sheet, it looks like hardware flow control (RTS, CTS) is enabled by default.  Do you have those pins connected and enabled as well?
     
    #3
    ryanjones
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/01/07 13:51:21
    • Location: 0
    • Status: offline
    Re: PIC32MZ UART Errata solution 2019/11/12 12:11:47 (permalink)
    0
    Justin Grantham
    Can you share your UART init code?  According to the errata this should not be present if you are operating in standard speed mode BRGH=0, which I have to assume you are based on the formula that your shared.
     
    Are you getting the baud rate you are calculating at least?


    UART init code is

    /* Set up UxMODE bits */
        /* STSEL  = 0*/
        /* PDSEL = 0 */
        /* BRGH = 0 */
        /* RXINV = 0 */
        /* ABAUD = 0 */
        /* LPBACK = 0 */
        /* WAKE = 0 */
        /* SIDL = 0 */
        /* RUNOVF = 0 */
        /* CLKSEL = 3 */
        /* SLPEN = 0 */
        U1MODE = 0x60000;

        /* Enable UART1 Receiver and Transmitter */
        U1STASET = (_U1STA_UTXEN_MASK | _U1STA_URXEN_MASK);

        /* BAUD Rate register Setup */
        U1BRG = 216;

        /* Turn ON UART1 */
        U1MODESET = _U1MODE_ON_MASK;

     
    Was getting the correct baud rate just with the shortened stop bit.
     
    Fixed the problem by setting the U1BRG to 220, which lengthened the stop bit enough for the modem to make sense of it. Got to 220 by just picking a number slightly larger than 216 🤷‍♂️
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5