How to configure receiver handler of LIN module on MPC5777M EVM board ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to configure receiver handler of LIN module on MPC5777M EVM board ?

643 Views
anishchoudhary
Contributor III

For LIN module on MPC5777M and MPC5748G EVM board ? I configure receiver handler for LIN slave that you can find in following lines :

if( LINFlexD_0.BIDR.B.ID == 0x35u ) //LINFlexD_1.BIDR.ID=0x35;(master)

{

    LINFlexD_0.LINCR2.B.DDRQ =0;

        while (!LINFlexD_0.LINSR.B.DRF);     

    /* wait for Receiving Message Buffer */
    while (1 != LINFlexD_0.LINSR.B.RMB)
    {
    // Wait from RMB
    }
        uint8_t __attribute__ ((unused)) RxBuffer[8] = {0} ;
        uint8_t i;

        for (i=0; i<4;i++)
        {                 /* If received less than or equal 4 data bytes */
            RxBuffer[i] = (LINFlexD_0.BDRL.R>>(i*8));
        }
        for (i=4; i<8;i++)
        {
            RxBuffer[i] = (LINFlexD_0.BDRM.R>>((i-4)*8));
        }

    LINFlexD_0.LINSR.R = 0x0207;

}

please find the code and check it out that is right or i must have to do some other configuration for that reception handler part in slave side ?

Tags (1)
2 Replies

481 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Code looks normal but it depends on Slave configuration:

- TX/RX interrupts enabled/disabled,

- RX and TX filter are active or no filters  are set,

- BF is set/cleared and

- received ID is matched or not.

Based one this, the program flow may differ. The possible sequences are given for example in chapter 59.5.2 „Slave node“ of the MPC5777M RM.

BR, Petr

481 Views
anishchoudhary
Contributor III

    Hi Petr,

Thank you for last replay its helpful for me. To confirm the LIN slave you can find the configuration in following lines: 

   LINFlexD_0.UARTCR.B.UART = 0 ;   // There is no meaning of LIN mode until UART bit is not reset in UARTCR register
    LINFlexD_0.LINCR1.B.INIT = 1 ;      // Put LINFlex hardware in init mode to come out reset that INIT bit

    LINFlexD_0.LINCR1.B.SLEEP = 0 ;                        // Disable the request of sleep mode in LIN
       while (0x1000 != (LINFlexD_0.LINSR.R & 0xF000))
       {
           // Wait for INIT mode of LIN module
       }

    LINFlexD_0.LINIBRR.B.IBR = 480 ; //baud rate
    LINFlexD_0.LINFBRR.B.FBR = 0 ; //fractional baud rate

    LINFlexD_0.LINCR2.R = 0x4000 ;         // avoid the idle state when bit error is come
    LINFlexD_0.LINTCSR.R = 0 ;                // Avoid that get slave in idle state

    LINFlexD_0.BIDR.B.CCS = 0x01u;                             // enhanced checksum for LIN Slave

    LINFlexD_0.IFER.R = 0xF;                            // enable filters 0-3
    LINFlexD_0.IFMR.R = 0x0;                            // filters 0 - 3 are in identifier list mode.
    LINFlexD_0.IFCR[0].R = 0x1E37;                    // 8bytes, TX data, ID=0x37, CCS=0
    LINFlexD_0.IFCR[1].R = 0x1C35;                    // 8bytes, RX data, ID=0x35, CCS=0
    LINFlexD_0.IFCR[2].R = 0x1F36;
    LINFlexD_0.IFCR[3].R = 0x1F35;                    // 8bytes, TX data, ID=0x35, CCS=1

    // LIN configure : MME=0,BF=1,MBL=3,INIT=0,AUTO=1
     LINFlexD_0.LINCR1.R = 0x00001380 ;

Please find the salve configuration and make me sure, that slave configuration is right or any modification if needed ?

0 Kudos