MPC574xP EVB(MPC5744P-144DS ) LIN mode can't receive any data by SW pooling or interrupt

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC574xP EVB(MPC5744P-144DS ) LIN mode can't receive any data by SW pooling or interrupt

442 Views
q380742432
Contributor I

I  use two  MPC574xP EVB   ,one of MPC574xP EVB's LIN1 as  slave  mode  another as  master mode 。The  configeration is shown below:

 slave mode config:

    LINFLEX_InitLIN(1, 200000000/2, 19200, 0);

    LINFLEX_InitRxBuffer(1,4);

master mode config:

    uint8_t lin_str[8]={0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0};

    LINFLEX_InitLIN(1, 200000000/2, 19200, 1);

    LINFLEX_InitRxBuffer(1,4);

     LINFLEX_SendFrameLIN (1, (uint8_t*)&lin_str, 0x08, 0x02);

void LINFLEX_InitLIN(vuint8_t nbLINFlex, double sysClk, uint32_t baudRate, uint8_t mode)
{

LINFLEX_ConfigurePads(nbLINFlex);

LINFLEX_WakeUp(nbLINFlex);

LINFLEX[nbLINFlex]->LINCR1.B.INIT = 1; // enter initialization mode
LINFLEX[nbLINFlex]->LINCR1.B.MBL = 3; //Master break length set to 13-bit
LINFLEX[nbLINFlex]->LINCR1.B.BF = 0; //Bypass filter -> no interrupt if ID does not match any filter
LINFLEX[nbLINFlex]->LINCR1.B.MME = mode; //1 -> Master, 0 -> Slave
LINFLEX[nbLINFlex]->LINTCSR.B.IOT = 0; //LIN state machine does not reset to Idle on timeout event
//LINFLEX[nbLINFlex]->LINCR1.B.LBKM = 1;

LINFLEX[nbLINFlex]->LINCR1.B.BF = 1;
LINFLEX[nbLINFlex]->LINCR1.B.CCD = 0;
LINFLEX[nbLINFlex]->LINCR1.B.CFD = 0;
LINFLEX[nbLINFlex]->LINCR2.B.IOBE = 0;
LINFLEX[nbLINFlex]->LINCR2.B.IOPE = 0;

LINFLEX[nbLINFlex]->UARTCR.B.UART = 0; //0=Lin

LINFLEX_ChangeBaudRate(nbLINFlex, sysClk, baudRate);

LINFLEX[nbLINFlex]->LINCR1.B.INIT = 0; // enter normal mode

}

void LINFLEX_SendFrameLIN (vuint8_t nbLINFlex, uint8_t* p_tx, uint8_t nbBytes, uint8_t ID)
{
//sends complete LIN frame on Master => header + data
uint32_t responseL=0;
uint32_t responseH=0;

if (nbBytes == 1)
{
responseL = p_tx[0];
}
else if (nbBytes == 2)
{
responseL = p_tx[0] | (p_tx[1] << 8);
}
else if (nbBytes == 3)
{
responseL = p_tx[0] | (p_tx[1] << 8) | (p_tx[2] << 16);//(uint32_t) p_tx[0] + ( ((uint32_t)p_tx[1]) * 256) + ( ((uint32_t)p_tx[2]) * 65536);
}
else if (nbBytes >= 4)
{
responseL = p_tx[0] | (p_tx[1] << 8) | (p_tx[2] << 16) | (p_tx[3] << 24);
}
if (nbBytes == 5)
{
responseH = p_tx[4];
}
else if (nbBytes == 6)
{
responseH = p_tx[4] | (p_tx[5] << 8);
}
else if (nbBytes == 7)
{
responseH = p_tx[4] | (p_tx[5] << 8) | (p_tx[6] << 16);//(uint32_t) p_tx[0] + ( ((uint32_t)p_tx[1]) * 256) + ( ((uint32_t)p_tx[2]) * 65536);
}
else if (nbBytes == 8)
{
responseH = p_tx[4] | (p_tx[5] << 8) | (p_tx[6] << 16) | (p_tx[7] << 24);
}

LINFLEX[nbLINFlex]->BDRL.R = responseL;
LINFLEX[nbLINFlex]->BDRM.R = responseH;

switch(nbBytes){ //number of data Bytes will be included into the IDentifier
case 2 : ID = 0x20 | ID; break; //0b10_0000 | ID; break;
case 4 : ID = 0x10 | ID; break; //0b01_0000 | ID; break;
case 8 : ID = 0x30 | ID; break; //0b11_0000 | ID; break;
}

LINFLEX[nbLINFlex]->BIDR.R = ((nbBytes - 1) << 10) | (1 << 9) | (0 << 8) | ID; //DIR - transmit, CCS - enhanced checksum

LINFLEX[nbLINFlex]->LINCR2.B.HTRQ = 1; 

while(LINFLEX[nbLINFlex]->LINSR.B.DTF!=1){}
LINFLEX[nbLINFlex]->LINSR.B.DTF=1;
}

interrupt  app:

void ISR380_LINFlEX1_Rx(void)
{
/* wait for RMB */
while (1 != LINFlexD_1.LINSR.B.RMB) {} /* Wait for Release Message Buffer */

LINFLEX_ReadLIN(1,0x8,lin1_Message);
LINFLEX_SendWordUART (0, (uint8_t*)&lin1_Message, sizeof(lin1_Message));
/* clear the HRF,DRF and RMB flags by writing 1 to them */
LINFlexD_1.LINSR.R = 0x0205;

}

0 Kudos
3 Replies

50 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

what is the MCU pin setting for master and slave?

How is the jumper setting on the EVB done?

Could you share LIN bus signal taken by scope?

There is a sample code posted here (https://community.nxp.com/docs/DOC-329922 ), but just single transceiver is used.

BR, Petr

0 Kudos

50 Views
q380742432
Contributor I

MCU pin set  :

void LINFLEX_ConfigurePads(vuint8_t nbLINFlex)
{

if(nbLINFlex == 0) //LINFLEX_0
{
SIUL_DigitalOutput(SIUL_PB2, SIUL_ALT1); // Tx
SIUL_DigitalInput(SIUL_PB3, SIUL_IN_PB3, 0, SIUL_ALT1); // Rx

}else{ //LINFLEX_1
SIUL_DigitalOutput(SIUL_PD9, SIUL_ALT2); //Tx
SIUL_DigitalInput(SIUL_PB13, SIUL_IN_PD12, 0, SIUL_ALT1); //Rx
}
}

0 Kudos

50 Views
PetrS
NXP TechSupport
NXP TechSupport

These functions gives us no idea how the respective SIUL registers are set.

So using your mentioned pins the setting should be

 

/* Configure pad PB2 for LIN0TX */

SIUL2.MSCR[18].B.SSS = 1;    /* Pad PB2: Source signal is LIN0_TXD  */

SIUL2.MSCR[18].B.OBE = 1;    /* Pad PB2: Output Buffer Enable */

SIUL2.MSCR[18].B.SRC = 3;    /* Pad PB2: Maximum slew rate */

 

/* Configure pad PB3 for LIN0RX */

SIUL2.MSCR[19].B.IBE = 1;    /* Pad PB3: Enable pad for input - LIN0_RXD */

SIUL2.IMCR[165].B.SSS = 1;   /* LIN0_RXD: connected to pad PB3 */

 

/* Configure pad PD9 for LIN1TX */

SIUL2.MSCR[57].B.SSS = 2;    /* Pad PD9: Source signal is LIN1_TXD  */

SIUL2.MSCR[57].B.OBE = 1;    /* Pad PD9: Output Buffer Enable */

SIUL2.MSCR[57].B.SRC = 3;    /* Pad PD9: Maximum slew rate */

 

/* Configure pad PB13 for LIN1RX */

SIUL2.MSCR[29].B.IBE = 1;    /* Pad PB13: Enable pad for input – LIN1_RXD */

SIUL2.IMCR[166].B.SSS = 1;   /* LIN1_RXD: connected to pad PB13 */

 

Or

/* Configure pad PD12 for LIN1RX */

SIUL2.MSCR[60].B.IBE = 1;    /* Pad PD12: Enable pad for input – LIN1_RXD */

SIUL2.IMCR[166].B.SSS = 2;   /* LIN1_RXD: connected to pad PD12 */

 

 

Then I assume you have proper EVB connection.

BR, Petr