Hot!MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L

Author
dvvrcognizant
New Member
  • Total Posts : 28
  • Reward points : 0
  • Joined: 2019/03/13 07:48:11
  • Location: 0
  • Status: offline
2019/03/27 04:43:38 (permalink)
0

MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L

I am trying to operate the UART with higher baud rates. The PIC32 Micro controller used is PIC32MC470F512L. I use MPLAB Harmony. The UART is configured  in loop back mode. I wrote a program to send and receive data. The program works well up to baud rate of 4915200 (approx 5Mbps). The same program does not work for baud rates greater than 4915200. I configured clock scheme such that the PBCLK is 96MHz.
 
Please suggest, if i need to do some more settings using MPLAB Harmony Configurator.
 
Due to file size limitation, I am unable to upload the "package" form of the MPLAB X Project.
#1

14 Replies Related Threads

    LostInSpace
    Super Member
    • Total Posts : 220
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/03/28 17:15:01 (permalink)
    0
    I always go and so a hand calculation (from the data sheet) of the baud rates for any clock frequency / baud rate setting that I want to use. You may find that you cant get there from that clock frequency. I then set in Harmony the exact baud setting that the hand calculation shows is possible.
     
    HTH
    #2
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/03/28 23:45:01 (permalink)
    0
    SteveHageman
    I always go and so a hand calculation (from the data sheet) of the baud rates for any clock frequency / baud rate setting that I want to use. You may find that you cant get there from that clock frequency. I then set in Harmony the exact baud setting that the hand calculation shows is possible.
     
    HTH




    I could not upload the screenshots of the MPLAB Harmony Configuration for "Clock" and "UART Driver".
    But, I uploaded the files at:
    https://www.microforum.cc/topic/53-mplab-harmony-configuration-settings-for-uart-higher-baud-rates-pic32mx470512l/
     
    Please check and let me know, if I miss any thing, due which higher baud rates (>4915200) do not work.
    #3
    Mysil
    Super Member
    • Total Posts : 3290
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/03/29 01:19:34 (permalink)
    0
    Hi,
    UART hardware in the PIC32, divide the Peripheral clock signal by the UART baudrate divider: UxBRG,
    and then either by 16, or by 4, in order to sample incoming UART signal  during the clock period.
     
    When dividing by 16 in 'Standard speed mode', the highest UART bitrate may be something like 6 MHz. 
    When dividing by 4 in 'High speed mode',  by setting UxMODE bit BRGH = 1, bitrate 24 MHz should be possible, with the 96 MHz clock frequency.
    See datasheet for the PIC32MX  device that you are using.
    Be aware that it is very limited, what selection of frequencies may be used.
     
    I have no idea if these settings can be specified thru the Harmony GUI.
     
        Mysil
    #4
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/01 05:20:20 (permalink)
    0
    Mysil
    Hi,
    UART hardware in the PIC32, divide the Peripheral clock signal by the UART baudrate divider: UxBRG,
    and then either by 16, or by 4, in order to sample incoming UART signal  during the clock period.
     
    When dividing by 16 in 'Standard speed mode', the highest UART bitrate may be something like 6 MHz. 
    When dividing by 4 in 'High speed mode',  by setting UxMODE bit BRGH = 1, bitrate 24 MHz should be possible, with the 96 MHz clock frequency.
    See datasheet for the PIC32MX  device that you are using.
    Be aware that it is very limited, what selection of frequencies may be used.
     
    I have no idea if these settings can be specified thru the Harmony GUI.
     
        Mysil


    Hi Mysil,
     
    Thanks for your input.
     
    I did the clock setting through Harmony GUI. The "Peripheral Bus Clock" is configured as 96MHz. As per the datasheet the maximum possible speed should be 24Mbps when BRGH=1. I verified using the debugger the value of BRGH and it is '1'.
     
    The baud rate that I was trying to configure earlier was "9830400". Now I realized that it is not a supported baud rate. So it was not working.
     
    With the help of the formula given in the "UART Section of PIC32MX Reference Manual", i calculated the four supported baud rate values, starting from the maximum value and they are 24Mbps, 12MHz, 8Mbps and 6Mbps. When I try to set these values, up to 8Mbps the UART communication between two PIC32s worked. But the baud rates 12Mbps and 24Mbps are not working.
     
    If you can find out more setting to be done to achieve these baud rates (24Mbps and 12MHz), please let me know.
     
    - Vishnuvardhan
    #5
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/01 05:27:40 (permalink)
    0
    SteveHageman
    I always go and so a hand calculation (from the data sheet) of the baud rates for any clock frequency / baud rate setting that I want to use. You may find that you cant get there from that clock frequency. I then set in Harmony the exact baud setting that the hand calculation shows is possible.
     
    HTH


    Hi Steve,
     
    Thanks for your input.
     
    The baud rate that I was trying to configure earlier was "9830400". Now I realized that it is not a supported baud rate. So it was not working.
     
    With the help of the formula given in the "UART Section of PIC32MX Reference Manual", i calculated the four supported baud rate values, starting from the maximum value and they are 24Mbps, 12MHz, 8Mbps and 6Mbps. When I try to set these values, up to 8Mbps the UART communication between two PIC32s worked. But the baud rates 12Mbps and 24Mbps are not working.
     
    Please suggest, any other suggestions/inputs.
    #6
    Mysil
    Super Member
    • Total Posts : 3290
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/03 11:41:59 (permalink)
    5 (1)
    Hi,
    There may be 2 different issues with what you are trying to do.
    1:  Generating the UART baudrate clock for the signaling frequency you want.
    I do think you have not ever been able to generate clock for 4 915 200 bit/s
    The nearest may have been 4 800 000 bit/s, which is 96 000 000 / 5 / 4.
    If using internal FRC oscillator, it is possible to tune the system clock frequency.
    Doubling the frequency to 9 600 000 bit/s will not be possible, since the BRG divider cannot divide by 2.5
     
    You might be able to achieve 9 830 400 bit/s
    by using 78 643 200 Hz system clock frequency divided by / 4 / 4.
    This may be done by using PLLMULT  = MULT20, and a little clock tuning if using FRC.
    7.864 MHz crystal may  also be possible, but is not very common.
     
    UART have some tolerance in clock frequency, since it resynchronize for every 10 bit times,
    at the transition from Stop bit to Start
    When testing in loopback mode, the actual bitrate clock do not matter anyway.
     
    2:   Harmony software performance.
    If testing in loopback mode, or if testing by transmitting between 2 UART modules in the same device,
    then the same PIC will have to handle both transmit and receive at the same rate.
    There is nowhere a promise that Harmony software will be able to keep up with the bitrate that may be serviced by the hardware peripheral.
     
    You may have to use custom software, or DMA transfer to keep up.
     
        Mysil
    #7
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/04 00:37:13 (permalink)
    0
    Hi Mysil,
     
    I want to operate the UART with "maximum supported speed".
    My hardware setup is like below:
    PIC32 Board Tx     PIC32 Board Rx
    -----------------     ------------------
    Tx----------------------->Rx
    GND----------------------GND
     
    There is a formula to calculate the Baud rate when bit BRGH = 1, in the reference manual, like below:
    Baud Rate = (FPB/(4 * (UxBRG + 1))
    FPB: Frequency of Peripheral Bus Clock
    BRG: Baud Rate Register
    With this formula, maximum supported baud rate would be 24,000,000 (24Mbps) when FPB is 96,000,000 (96MHz) and BRG = 0.
    The clock scheme is like below:
    POSC = 8MHz ---> System PLL ---> 96MHz ---> SYSCLK & PBCLK
     
    I wrote two programs, "Tx Program" and "Rx Program".
    Tx Program: Runs on "PIC32 Board Tx".
    Rx Program: Runs on "PIC32 Board Rx".
    The program uses UART driver generated by Harmony. I configured the driver to operate UART with DMA. 
    The "Tx Program" is able to send out data through UART.
    But the "Rx Program" fails to receive data through UART.
     
    Please suggest if I need to do more settings in Harmony or any registers.
    Or still I need to write my own code to receive data through UART.
     
    Thanks & Regards,
    Vishnuvardhan
    #8
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/09 06:54:27 (permalink)
    0
    Today, I tried to debug the issue further. I found that there is Overrun Error. This error is present at lower baud rates like 9600 also. Due to this error, at the receiving end, few data bytes are received and then the UART does not receive data further. 

    After using the API "USART_ReceiverOverrunErrorClear_Default()" the UART does not stop receiving data when Overrun Error occurs. But still received data is erroneous. So, at the transmission end added a delay of few milli seconds. With the addition of delay, no errors are seen. The receiving works at baud rate of 24Mbps also.
     
    Please suggest, the way to overcome/handle the overrun errors.
    ---------------------------------------------------------------------------------------------------------------------------------
    Clocks used:
    --------------
    POSC is 8MHz. SYSCLK is 96MHz. PBCLK also 96MHz. So the maximum supported baud rate is 24MHz (96MHz/4) when BRGH bit is '1' and BRG register value is '0'. 
     
    The hardware we use are:
    -----------------------------
    PIC32 USB Starter Kit III and Starter Kit I/O Expansion Board. 
     
    The software we use are:
    ----------------------------
    MPLAB X IDE and Harmony. 
    UART Driver used is "Dynamic driver - buffer queue model with DMA". This driver code is generated by Harmony. 
    #9
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/09 21:43:14 (permalink)
    0
    I created Microchip support case: https://microchipsupport.force.com/5001N00000q4HQW
    Case ID: 
    00401440
    #10
    aatifshaikh66
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/02/20 03:17:39
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/11 23:08:21 (permalink)
    0
    Hi all,
     
    I also wanted to use a high baud rate (more than 1Mbps) in my projects, but unfortunately, any serial terminals (Hyperterminal, RealTerm, TeraTerm, etc) that I came across support maximum baud rate up to 921600. Hence, is there any terminal software (I need it for debugging or monitoring data) which can support baud rate higher than 1Mbps? 

    Thanking with Regards,
    Aatif Shaikh
    #11
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/11 23:12:34 (permalink)
    0
    I think, it's not the terminal software that limits but it is the UART Chip on "USB To Serial Converter" that you use.
    #12
    aatifshaikh66
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/02/20 03:17:39
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/11 23:34:50 (permalink)
    0
    Thanks for your kind information, but I already know that (I'm using CP2102 USB-TO-UART which support up to 12Mbps). My only concern was, maybe you were using or know anything about any software (support higher than 921600 baud rate) which can be used to monitor the data flow or debugging. Controller to controller I've used many high baud rate, but I wanted to know more about controller to PC (sometimes helps in data logging as well).
    #13
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/12 00:02:30 (permalink)
    4 (1)
    Try "putty", in it we can enter baud rate manually.
    #14
    dvvrcognizant
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2019/03/13 07:48:11
    • Location: 0
    • Status: offline
    Re: MPLAB Harmony Configuration Settings for UART Higher Baud rates - PIC32MX470512L 2019/04/14 21:23:34 (permalink)
    0
    Hi All,
     
    Did anyone get a chance see my code?
     
    Thanks & Regards,
    Vishnuvardhan
    #15
    Jump to:
    © 2019 APG vNext Commercial Version 4.5