I used this example
I want to use LIN interrupts, is there an example I can refer to?
and during the example test
-----------------------------------------------------------------
static void LIN0_ReceiveData(uint16_t bidr_value)
{
/* Master to receive x bytes with ID and CCS from bidr_value */
LINFLEX_0.BIDR.R = bidr_value;
/* Trigger Frame transmission */
LINFLEX_0.LINCR2.B.HTRQ = 1;
/* wait until Slave response to the LIN header has been receive successfully */
while(0 == LINFLEX_0.LINSR.B.DRF)
{
/* track LIN Status for errors */
// stop here
}
/* read BDR registers */
rx_data[0] = LINFLEX_0.BDRL.B.DATA0;
rx_data[1] = LINFLEX_0.BDRL.B.DATA1;
rx_data[2] = LINFLEX_0.BDRL.B.DATA2;
rx_data[3] = LINFLEX_0.BDRL.B.DATA3;
rx_data[4] = LINFLEX_0.BDRM.B.DATA4;
rx_data[5] = LINFLEX_0.BDRM.B.DATA5;
rx_data[6] = LINFLEX_0.BDRM.B.DATA6;
rx_data[7] = LINFLEX_0.BDRM.B.DATA7;
/* clear RMB, HRF, DRF and DTF flags */
LINFLEX_0.LINSR.R = 0x0207;
}
------------------------------------------------------------
When data is received it works fine, but when no data is received it stops at the while statement. Is there any way to solve this?
please help thank you
Hi,
Slave example enables TX and RX interrupt, so you can refer to it. In master mode if node publish data, TX interrupt (DTF flag) will be called after node transmit frame. If node request data, then RX interrupt (DRF flag) will be called after response is received.
Timeout counter can be used to detect no response (frame timeout), see more in chapter 21.8.3 8-bit timeout counter of the RM.
BR, Petr