MPC5744P LinFlexD Slave Communication

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MPC5744P LinFlexD Slave Communication

512 次查看
Vennila
Contributor I

Hi,

I'm using LinFlexD on MPC5744P EV-board. 

configured MPC5744P as slave, PLIN hardware [with monitor software, able to configure as master and slave modes] as Master.  

Flashed the S32 design studio LINFLexD_LIN_Slave_MPC5744P example code to EV board. and trying to send data from PLIN viewer to MPC5744P. Did not get any response from Slave.   

Program struck in  while(!(LINFlexD_0.LINSR.B.HRF));    /* Wait for header to be received */ 

//INIT Function

void initLINFlexD_0 (void) {     /* Slave at 10.417K baud with 80MHz LIN_CLK */
 
LINFlexD_0.LINCR1.B.INIT = 1;    /* Put LINFlex hardware in init mode */
LINFlexD_0.LINCR1.R= 0x00000301; /* Configure module as LIN slave */
LINFlexD_0.LINIBRR.B.IBR= 480; /* Mantissa baud rate divider component */
/* Baud rate divider = 80 MHz LIN_CLK input / (16*10417K bps) ~=480 */
LINFlexD_0.LINFBRR.B.FBR = 0; /* Fraction baud rate divider comonent */
LINFlexD_0.LINCR2.R = 0x40; /* IOBE=1, Bit error resets LIN state machine */
LINFlexD_0.LINTCSR.R = 0; /* LIN timeout mode, no idle on timeout */
LINFlexD_0.BIDR.B.CCS = 0; /* enhanced checksum for LIN Slave */
LINFlexD_0.LINIER.R = 0x7; // enable RX, TX and header interrupt
LINFlexD_0.LINCR1.R = 0x00000380;
 
/* Configure LINFlexD_0 TxD Pin. */
SIUL2.MSCR[PB2].B.SSS = 0b0001; //Pad PF14: Set to LINFlex_1 TxD. Must choose this option because F14 leads to LIN PHY of motherboard
SIUL2.MSCR[PB2].B.OBE = 1; //Enable output buffer
SIUL2.MSCR[PB2].B.src=3; //Full drive-strength without slew rate control
 
/* Configure LINFlexD_0 RxD Pin. */
SIUL2.MSCR[PB3].B.IBE = 1; //Pad PF15: Enable input buffer
SIUL2.IMCR[165].B.SSS = 0b0001; //Connect LINFlexD_2 signal to PF15
}

 

// Receive function 

void receiveLINframe_0 (void) {      /* Request data from ID 0x15 */
uint8_t i;
while(!(LINFlexD_0.LINSR.B.HRF));  /* Wait for header to be received */
/* Read the identifier. Look for ID=0x35 */
if(LINFlexD_0.BIDR.B.ID == 0x35){
LINFlexD_0.LINSR.R |= 0x00000001; /* Clear the HRF flag */
/* If ID=0x35, receive bytes from master. Configure the data length */
LINFlexD_0.BIDR.B.DFL = 7; //Receive 8 bytes. DFL = number of data bytes - 1 = 8-1 = 7
/* Configure checksum for enhanced checksum */
LINFlexD_0.BIDR.B.CCS = 0;
 
/* Configure to receive */
LINFlexD_0.BIDR.B.DIR = 0;
 
/* Wait for DRF bit to be set */
while(!(LINFlexD_0.LINSR.B.DRF));
 
/* Read the data bytes */
for (i=0; i<4;i++){         /* If received less than or equal 4 data bytes */
RxBuffer[i]= (LINFlexD_0.BDRL.R>>(i*8)); /* Fill buffer in reverse order */
}
for (i=4; i<8;i++){         /* If received more than 4 data bytes: */
RxBuffer[i]= (LINFlexD_0.BDRM.R>>((i-4)*8)); /* Fill rest in reverse order */
if(RxBuffer[i]){}
}
 
/* Clear DRF and release message buffer */
LINFlexD_0.LINSR.R = 0x00000204;
 
TransmitData((const char*)Message2,strlen((const char*)Message2));
TransmitData((const char*)RxBuffer,8);
TransmitData((const char*)newline,strlen((const char*)newline));
 
/* Read the identifier. Look for ID=0x15 */
}else if(LINFlexD_0.BIDR.B.ID == 0x15){
/* If ID=0x15, send btyes to master.
* Fill the buffer with "World   ".
*/
LINFlexD_0.BDRL.B.DATA0 = 'W';
LINFlexD_0.BDRL.B.DATA1 = 'o';
LINFlexD_0.BDRL.B.DATA2 = 'r';
LINFlexD_0.BDRL.B.DATA3 = 'l';
LINFlexD_0.BDRM.B.DATA4 = 'd';
LINFlexD_0.BDRM.B.DATA5 = ' ';
LINFlexD_0.BDRM.B.DATA6 = ' ';
LINFlexD_0.BDRM.B.DATA7 = ' ';
 
/* Wait for LINSR[RXbusy] to clear. Cannot set
* DIR and DTRQ if RXbusy is set.
*/
while(LINFlexD_0.LINSR.B.RXbusy);
 
/* Program CCS and DIR */
LINFlexD_0.BIDR.B.CCS = 0; //Enhanced checksum
LINFlexD_0.BIDR.B.DIR = 1; //Send bytes to master
 
/* Specify number of bytes to send */
LINFlexD_0.BIDR.B.DFL = 7; //Send 8 bytes. DFL = number of data bytes - 1 = 8-1 = 7
 
/* Trigger data transmission */
LINFlexD_0.LINCR2.R |= 0x00000400; //Set LINCR2[DTRQ] to transmit data
 
/* Clear HRF finally. DTRQ must be set while HRF=1
* in order to prevent random setting of DTRQ.
*/
LINFlexD_0.LINSR.R |= 0x00000001;
 
/* Wait for transmission to complete */
while(!(LINFlexD_0.LINSR.B.DTF));
 
/* Clear DTF */
LINFlexD_0.LINSR.R |= 0x00000002;
 
/* Print the message */
TransmitData((const char*)Message1,strlen((const char*)Message1));
}
 
}

 

  1. EV-board as master, PLIN Viewer as slave. tried to send data and able to receive data in PLIN Viewer. 
  2. PLIN as master and EV-board as slave, slave not responding when sending data from master to slave. Slave not responding.  

Captured the break + sync+ protected ID when probing the LIN line using oscilloscope.  

Please help me with this problem.  

 

Reference  image

LIN Configuration Register Values:

Vennila_0-1714459272730.png

 

 

LIN status register 

Vennila_1-1714459272734.png

 

 

LIN Error status register

Vennila_2-1714459272736.png

 

 

 

Thanks, and Regards  

Vennila 

 

 

 

 

0 项奖励
回复
3 回复数

458 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

seems you got Sync field error. Try to enable autosynchronization using LASE bit.
Some example can be also found on https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5744P-LIN-Master-Slave-test-GHS614/ta....

BR, Petr

0 项奖励
回复

444 次查看
Vennila
Contributor I

 

Hi Petr

I enable LASE bit for autosynchronization and tried to receive. Now LINS = 0100 in LINSR Reg and SZF=1, OCF=1 in LINESR register. Not received the Header. 

Added Time-Out control register and status register image for reference. 

MPC5744_slave_LASE.PNG

MPC5744_slave_TCSR.PNG

Thanks, and Regards

Vennila 

0 项奖励
回复

376 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

please specify a board you have exactly (name, rev.).
Also try to measure LIN and slave TXD/RXD signals to be sure transceiver is active.

BR, Petr

0 项奖励
回复