AnsweredAssumed Answered

LIN

Question asked by monica bagade on Apr 18, 2017
Latest reply on Apr 20, 2017 by Petr Stancik

Hello,

I am trying to learn LIN functionality on MPC5634m. In this I have tried basic transfer of single message using following code.


#include "mpc563m.h" /* Use proper include file such as mpc5510.h or mpc5554.h */

 

 

const uint8_t FrameSpecAndData[] = {0x35,0x08,0xD0,'H','e','l','l','o',' ',' ',' '}; 
uint8_t  RecData; 

void initSysclk (void) {
    FMPLL.ESYNCR1.B.CLKCFG = 0X7;       /* Change clk to PLL normal mode from crystal */ 
    FMPLL.SYNCR.R = 0x16080000;         /* 8 MHz xtal: 0x16080000; 40MHz: 0x46100000 */
    while (FMPLL.SYNSR.B.LOCK != 1) {}; /* Wait for FMPLL to LOCK  */
    FMPLL.SYNCR.R = 0x16000000;         /* 8 MHz xtal: 0x16000000; 40MHz: 0x46080000 */
}

void initESCI_B (void) {
     ESCI_B.CR2.R = 0x6240;      /* Module is enabled, 13 bit break, stop on errors */
     ESCI_B.CR1.R = 0x0180000C;  /* 10417 baud, 8 bits, no parity, Tx & Rx enabled */
     ESCI_B.LCR.R = 0x01000000;  /* eSCI put in LIN mode */
     SIU.PCR[91].R = 0x400;      /* Configure pad for primary func: TxDB */
    SIU.PCR[92].R = 0x400;      /* Configure pad for primary func: RxDB */
}

void TransmitData (void) {
  uint8_t j;                                      /* Dummy variable */
 
  for (j=0; j< sizeof (FrameSpecAndData); j++) {    /* Loop for character string */
        while (ESCI_B.SR.B.TXRDY == 0) {}               /* Wait for LIN transmit ready = 1 */
        ESCI_B.SR.R = 0x00004000;                       /* Clear TXRDY flag */
        ESCI_B.LTR.R = FrameSpecAndData[j];      /* Write byte to LIN Trans Reg. */
  }
}

void ReceiveData (void) {
    while (ESCI_B.SR.B.RXRDY == 0) {}   /* Wait for LIN transmit ready = 1 */
    ESCI_B.SR.R = 0x00008000; 
    RecData = ESCI_B.LRR.R;             /* Read byte of Data*/
    ESCI_B.LRR.R = RecData;            /* Echo back byte of Data read */
}


void main(void) {
    initSysclk();       /* Set sysclk = 64MHz running from PLL */
    initESCI_B();       /* Enable Tx for 10417 baud, 8 bits, no parity */
    TransmitData();     /* Transmit string of characters on eSCI B */
    ReceiveData();
    while (1) {}        /* Wait forever */
}

 

 

If I want to transmit multiple messages. How to do that?

Can i transfer multiple messages with same ID?

Is there any demo code with the help of DMA transfer?

 

Please help me out?

Thanks in advance.

Outcomes