mpc5744 LinFlexD master Tx problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mpc5744 LinFlexD master Tx problem

Jump to solution
3,194 Views
jefferson_ll
Contributor III

Dear NXP,

I'm using LinFlexD on MCP5744 microcontroller with official EV-board.
According to sample code "Example MPC5744P LIN Master Slave test GHS614".
I have setting LinFlexD_1 as master same as sample code.

After writing data to BDRM buffer then write BIDR to trigger FlexLinD_1 to send frame but I can't find any break and sync frame signal.
There was no any signal appeared on the LA.

I have tried the PF14 and PF15 configure as UART mode and they could send data from Tx.


Please help me with this problem. Thank you.

FlexLin_1 setting as following:

//---- Initial setting ------
void Drv_LinFlexD1_init(void)
{

//-------- Pad setting --------------------

/* Configure pad PF14 for AF1 func: LIN1TX */
SIUL2.MSCR[94].R = 0; //Jeff add
SIUL2.MSCR[94].B.SSS = 1; /* Pad PF14: Source signal is LIN1_TXD */
SIUL2.MSCR[94].B.OBE = 1; /* Pad PF14: Output Buffer Enable */
SIUL2.MSCR[94].B.ODE = 1; /* Pad PF14: Output Drain Enable */
SIUL2.MSCR[94].B.PUS = 1; /* Pad PF14: Pull up selected */
SIUL2.MSCR[94].B.PUE = 1; /* Pad PF14: Pull Enable */
SIUL2.MSCR[94].B.SRC = 3; /* Pad PF14: Maximum slew rate */

/* Configure pad PF15 for LIN1RX */
SIUL2.MSCR[95].B.IBE = 1; /* Pad PF15: Enable pad for input - LIN1_RXD */
SIUL2.IMCR[166].B.SSS = 3; /* LIN1_RXD: connected to pad PF15 */

//----Lin 1 initial

/* enter INIT mode */
LINFlexD_1.LINCR1.R = 0x0081; /* SLEEP=0, INIT=1 */

/* wait for the INIT mode */
while (0x1000 != (LINFlexD_1.LINSR.R & 0xF000)) {}


/* configure baudrate 19200 */
/* assuming 100 MHz baud clock (halfsys_clk below)*/
/* LFDIV = halfsys_clk / (16 * desired baudrate)
LINIBRR = integer part of LFDIV
LINFBRR = 16 * fractional part of LFDIV (after decimal point)

for instance:
LFDIV = 100e6/(16*19200) = 325.5208
LINIBRR = 325
LINFBRR = 16*0.5298 = 8
*/
LINFlexD_1.LINFBRR.R = 8;
LINFlexD_1.LINIBRR.R = 325;

LINFlexD_1.LINCR2.R = 0x40; /* IOBE=1, Bit error resets LIN state machine */
LINFlexD_1.LINTCSR.R = 0; /* LIN timeout mode, no idle on timeout */

LINFlexD_1.LINCR1.R = 0x0390;
}

//---- Send data ------
void Drv_Drv_LinFlexD1_Send(void)
{
/* store the data in the message buffer BDR */
LINFlexD_1.BDRL.B.DATA0 = 'H';
LINFlexD_1.BDRL.B.DATA1 = 'e';
LINFlexD_1.BDRL.B.DATA2 = 'l';
LINFlexD_1.BDRL.B.DATA3 = 'l';

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

/* Master to publish x bytes with ID and CCS from bidr_value */
LINFlexD_1.BIDR.R = 0x1E35;

/* wait until Master response to the LIN header has been sent successfully */
while(0 == LINFlexD_1.LINSR.B.DTF)
{
/* track LIN Status for errors */
}

LINFlexD_1.LINSR.R = 0x0002; /* clear the DTF bit */
}

Tags (2)
1 Solution
2,204 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Jeff,

now I found you forgot to trigger header/frame transmission by setting CR2[HTRQ] bit after writing to BIDR. Use

LINFlexD_1.BIDR.R = 0x1E35;

LINFlexD_1.LINCR2.B.HTRQ = 1;    /* Trigger Frame transmission */

BR, Petr

View solution in original post

6 Replies
2,204 Views
jefferson_ll
Contributor III

Hi Petr,

 

 

According to your suggestion, when LinflexD as master needs to set HTRQ so that break, sync frame could be sent and appear on Tx pad.

Now the LinflexD as master could send or receive data from slave.

Thanks for your help.

 

 

The next topic using LinFlexD as slave with no filter.

The following initial setting the same as master, the only one difference is MME set 0.

void Drv_LinFlexD1_init(void)

{

          /* enter INIT mode */

  LINFlexD_1.LINCR1.R = 0x0081; /* SLEEP=0, INIT=1 */

 

  /* wait for the INIT mode */

  while (0x1000 != (LINFlexD_1.LINSR.R & 0xF000)) {}

 

  LINFlexD_1.LINFBRR.R = 8;

  LINFlexD_1.LINIBRR.R = 325;

 

  LINFlexD_1.LINCR2.R = BIT17_BIG; /* IOBE=1, Bit error resets LIN state machine */

 

  LINFlexD_1.LINTCSR.R = 0;  /* LIN timeout mode, no idle on timeout */

 

          //-------- Pad setting --------------------

  /* Configure pad PF14 for AF1 func: LIN1TX */

  SIUL2.MSCR[94].R = 0;        

  SIUL2.MSCR[94].B.SSS = 1;    /* Pad PF14: Source signal is LIN1_TXD  */

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

  SIUL2.MSCR[94].B.ODE = 1;    /* Pad PF14: Output Drain Enable */

  SIUL2.MSCR[94].B.PUS = 1;    /* Pad PF14: Pull up selected */

  SIUL2.MSCR[94].B.PUE = 1;    /* Pad PF14: Pull Enable */

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

 

 

  /* Configure pad PF15 for LIN1RX */

  SIUL2.MSCR[95].B.IBE = 1;    /* Pad PF15: Enable pad for input - LIN1_RXD */

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

 

  LINFlexD_1.LINCR1.B.MBL = 3;

  LINFlexD_1.LINCR1.B.MME =0;

 

  //---Interrupt unmask

 

  INTC_0.PSR[380].R = 0x8003;

  INTC_0.PSR[381].R = 0x8003;

  INTC_0.PSR[382].R = 0x8003;

 

 

  LINFlexD_1.LINSR.R = 0xFFFFFFFF;      //Clear interrupt flag

  LINFlexD_1.LINIER.B.DTIE = 1;                        //Data Transmitted Interrupt enable

  LINFlexD_1.LINIER.B.DRIE = 1;                        //Data Transmitted Interrupt enable

 

  LINFlexD_1.LINCR1.B.INIT =0;

  /* wait for the INIT mode */

  while (0x2000 != (LINFlexD_1.LINSR.R & 0xF000)) {}

 

}

 

 

 

Then the master always sends header to send or receive data from slave during initialization.

 

I have a question:

1.After slave initial done. And HRF bit is 1.

          The LINFlexD_LINSR shows 0x7141.

          The LINFlexD_LINESR shows 0x5100.

 Lin_slave.jpg

Why it always shows frame error?

And LINFlexD_LINSR.LINS=7 shows received and Identifier field is available?

Is there have slave coding procedure to reference?

Please give me some help thanks.

 

 

0 Kudos
Reply
2,203 Views
PetrS
NXP TechSupport
NXP TechSupport

HI Jeff,

The "Example MPC5744P LIN Master Slave test GHS614" shows LINFlex Slave implementation too.

Did you check the setting? The filter is enabled in this code.

You can also refer to the MPC5604B LIN Slave demo posted here: https://community.nxp.com/docs/DOC-102526

Once Filter is bypassed the SW polling is used to receive transmit data.

BR, Petr

0 Kudos
Reply
2,204 Views
jefferson_ll
Contributor III
Hi Petr,
I have checked the slave initialize setting and it's correct.
The only one thing is that HRF bit needs to check so that software could determine to receive or transfer data.
I have found how the LinFlexD slave transfer or receive under by-pass filter case.
Thanks for your hard support and sample code.
0 Kudos
Reply
2,204 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Jeff,

Do you have all jumpers around LIN transceiver properly installed?

For master node following is needed on the EVB:

J17 - LIN_TX ON

J16 - LIN_RX ON

J15 - LIN_EN ON

J8 – MASTER ON

P3 1-2 ON ... VSUP to 12V

 

See LIN signal on P3.3 or J4.4.

BR, Petr

0 Kudos
Reply
2,204 Views
jefferson_ll
Contributor III

Hi Petr,

Thanks for your reply.
I have installed all jumpers.
I want to know why LinFlexD_1 Tx doesn't have any signal.

I have tried the PF14 and PF15 configure as UART mode and they could send data from Tx or receive data from Rx.

Does the LinFlexD_1 setting is correct ??

0 Kudos
Reply
2,205 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Jeff,

now I found you forgot to trigger header/frame transmission by setting CR2[HTRQ] bit after writing to BIDR. Use

LINFlexD_1.BIDR.R = 0x1E35;

LINFlexD_1.LINCR2.B.HTRQ = 1;    /* Trigger Frame transmission */

BR, Petr