MPC5746C LIN Master Slave

Showing results for 
Search instead for 
Did you mean: 

MPC5746C LIN Master Slave

Contributor V


I am having an issue setting up the LIN Master Slave.

It seems that I am not the only one having issues. LINflexd transmission issue 

I tried following the example Martin Kovar suggested in this post Problem with LINFlexD LIN frame transmit 

I tried both LINFlexD_0 and LINFlexD_1.

It's still not working and don't know what else to try.

It gets stuck at while(0 == LINFlexD_0.LINSR.B.DTF) with LINFlexD_0.LINESR.B.BEF = 1

Hopefully somebody knows whats going on.


The rest is code. It's practically identical to the example. 

// Pin initialization is pretty standard. LINFlexD_0 works in UART and DMA mode, so I know the pins are correct.

// I'm not terribly sure about Pull-ups or Drain, but I don't think they matter at this point.

void LIN_lin0_pins_config(void)
SIUL2.MSCR[PB2].R = 0; // Initialize Register
SIUL2.MSCR[PB2].B.PUS = 1; // Pullup Selected
SIUL2.MSCR[PB2].B.PUE = 1; // Pullup Enable

SIUL2.MSCR[PB2].B.SSS = 1; // Source signal is LIN0_TX
SIUL2.MSCR[PB2].B.OBE = 1; // Output Buffer Enabled
SIUL2.MSCR[PB2].B.ODE = 1; // Output Drain Enabled
SIUL2.MSCR[PB2].B.SRC = 3; // Full strength slew rate

SIUL2.MSCR[PB3].B.IBE = 1; // Input Buffer Enabled
SIUL2.IMCR[712-512].B.SSS = 2; // Source signal is LIN0_RX

//The initialization of LINFlexD_0 for LIN mode seems pretty easy. (Not showing baud rate)

LINFlexD_0.LINCR2.R = 0x0;
LINFlexD_0.LINTCSR.R = 0x0; // LIN timeout mode, no idle on timeout
LINFlexD_0.LINCR2.B.IOBE = 1; // IOBE Enabled
LINFlexD_0.LINCR1.B.MBL = 0x3; // 13-bit LIN Master break length
LINFlexD_0.LINCR1.B.BF = 1; // An RX interrupt is generated on identifier not matching any filter
LINFlexD_0.LINCR1.B.MME = 1; // Master Mode Enabled

// This is pretty much the same as in the example.

void LIN_0_xmt_frame(const unsigned short _bidr_value)

// Store the data in the message buffer BDR
LINFlexD_0.BDRL.B.DATA0 = 'H';
LINFlexD_0.BDRL.B.DATA1 = 'e';
LINFlexD_0.BDRL.B.DATA2 = 'l';
LINFlexD_0.BDRL.B.DATA3 = 'l';

LINFlexD_0.BDRM.B.DATA4 = 'o';
LINFlexD_0.BDRM.B.DATA5 = '!';
LINFlexD_0.BDRM.B.DATA6 = '!';
LINFlexD_0.BDRM.B.DATA7 = '!';

// Set BIDR Register
LINFlexD_0.BIDR.R = 0; // Reset the Register
LINFlexD_0.BIDR.B.ID = 0x35; // The ID
LINFlexD_0.BIDR.B.CCS = 0; // (0: Enhance. Cover data and Identifier.)( 1: Classic. Only covers data. )
LINFlexD_0.BIDR.B.DIR = 1; // (0: Receive)(1: Transmit)
LINFlexD_0.BIDR.B.DFL = 0x7; // Number of data bytes - 1

// Trigger Frame transmission

// wait until Master response to the LIN header has been sent successfully
while(0 == LINFlexD_0.LINSR.B.DTF)
; //Do nothing

LINFlexD_0.LINSR.B.DTF = 1; // clear the DTF bit


Labels (1)
Tags (3)
0 Kudos
2 Replies

NXP TechSupport
NXP TechSupport


have you checked the too?

The code looks normal, sets LINFlex0 to LIN master mode and transmit frame. Open drain with weak pull up on TX line is not needed, but it should work too.

There could be issue with transceiver. Is it properly powered? On the EVB it is powered from the bus. Do you use EVB too? 

To test master transmit you can simply connect TX/RX pin together without transceiver, to know pins are properly set.

You should see full frame on this loopback connection.

BR, Petr

0 Kudos

Contributor V

I haven't had time to come back to this issue. When I do, I will let you know what happened. Thanks

0 Kudos