AnsweredAssumed Answered

MPC5746C LIN Master Slave

Question asked by Christopher Holland on Apr 4, 2019
Latest reply on May 3, 2019 by Christopher Holland

Hi,

 

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.

 

Thanks,

The rest is code. It's practically identical to the example. Example MPC5744P LIN Master Slave test GHS614 

 

 

// 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
LINFlexD_0.LINCR2.B.HTRQ = 1;

// 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

}

Outcomes