MPC5748G UART misses a character at 115200

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5748G UART misses a character at 115200

396 Views
kfirbs
Contributor III

hi,

 

trying to set baudrate of uart to 115200 on DEVKIT for MPC5748G, is missing a character once in a while:

    uart_init(80, 115200);       /* Initialize LINFlex2: UART Mode 80MHz, 115200 Baud */


void uart_init(uint32_t MegaHertz, uint32_t BaudRate)
{
    /*
     * Baud Rate = LINCLK / (16 x LFDIV)
     * LINCLK = BR x (16 x LFDIV)
     * LINCLK / (BR x 16) = LFDIV
     *
     * LFDIV = Mantissa.Fraction.
     * Mantissa = LINIBRR
     * Fraction = LINFBRR / 16
     *
     * Baud Rate = LINCLK / (16 x LINIBRR.(LINFBRR / 16))
     * LINIBRR.(LINFBRR / 16) = LINCLK / (BR x 16)
     * LINIBRR = Mantissa[LINCLK / (BR x 16)]
     * Remainder =  LINFBRR / 16
     * LINFBRR = Remainder * 16
     * The Remainder is < 1, So how does the Remainder work during a divide?
     * May be best to use a table?
     *
     * For Reference & Quick Tests
     * LINFLEX_x.LINIBRR.R = 416;                   // 9600 at 64MHz
     * LINFLEX_x.LINFBRR.R = 11;
     *
     * LINFLEX_x.LINIBRR.R = 781;                   // 9600 at 120MHz
     * LINFLEX_x.LINFBRR.R = 4;
     */
    uint32_t Fraction;
    uint32_t Integer;

    LINFlexD_2.LINCR1.B.INIT = 1;  /* Enter Initialization Mode */
    LINFlexD_2.LINCR1.B.SLEEP = 0; /* Exit Sleep Mode */
    LINFlexD_2.UARTCR.B.UART = 1;  /* UART Enable, Req'd before UART configuration */
    LINFlexD_2.UARTCR.B.RxEn = 1;
    LINFlexD_2.UARTCR.B.TxEn = 1;
    LINFlexD_2.UARTCR.B.RFBM = 0;
    LINFlexD_2.UARTCR.B.WL0 = 0x1;
    LINFlexD_2.UARTCR.B.PCE = 1;
    //LINFlexD_2.UARTCR.R = 0x0033;     /* UART Enable, 1 byte tx, no parity, 8 data*/
    LINFlexD_2.UARTSR.B.SZF = 1;    /* CHANGE THIS LINE   Clear the Zero status bit */
    LINFlexD_2.UARTSR.B.DRFRFE = 1; /* CHANGE THIS LINE  Clear DRFRFE flag - W1C */

    BaudRate = (MegaHertz * 1000000) / BaudRate;
    Integer = BaudRate / 16;
    Fraction = BaudRate - (Integer * 16);

    LINFlexD_2.LINIBRR.R = Integer;
    LINFlexD_2.LINFBRR.R = Fraction;
    LINFlexD_2.LINIER.B.DRIE = 1;

    LINFlexD_2.LINCR1.B.INIT = 0; /* Exit Initialization Mode */

    SIUL2.MSCR[PC8].B.SSS = 1; /* Pad PC8: Source signal is LIN2_TX  */
    SIUL2.MSCR[PC8].B.PUS = 1; /* by Kfir: Tx need to be pulled up - prevent junk chars  */
    SIUL2.MSCR[PC8].B.PUE = 1; /* by Kfir: Tx need to be pulled up - prevent junk chars  */
    SIUL2.MSCR[PC8].B.OBE = 1; /* Pad PC8: OBE=1. */
    SIUL2.MSCR[PC8].B.src=3; /* Pad PC8: Full strength slew rate */
    SIUL2.MSCR[PC9].B.IBE = 1; /* Pad PC9: Enable pad for input */
    SIUL2.IMCR[202].B.SSS = 2; /* LIN2_RX : connected to pad PC9 */

    LINFlexD_2.LINIER.B.DRIE = 1; /* Enable RX interrupt */
}

 

example:

"result": "PASS", "file": "

output:

"rsult": "PAS", "file":

What can be the reason?

Tags (3)
0 Kudos
2 Replies

366 Views
kfirbs
Contributor III

Can someone please enlighten me?

0 Kudos

390 Views
kfirbs
Contributor III

BTW, This also happens in the example application created by S32 with application linflexd_uart While changing the baudrate from 56700 to 115200.

 

adding application here.

0 Kudos