AnsweredAssumed Answered

about   S32KSDK  lin_master_baremetal_s32k148

Question asked by 王强 王 on Jun 19, 2020
Latest reply on Jul 16, 2020 by Petr Stancik

When lin is used as the Master and the LIN host scheduling table has multiple ID, when receiving and sending are processed at the same time in the LIN interrupt, ID data loss and garbled code will occur.The following is my source code, please take a look at it for me,thanks

this is lin callback function:

 lin_callback_t lin_rx_tx_handle_callback(uint32_t instance, lin_state_t * lin1_State)
{
lin_callback_t callbackCurrent;
callbackCurrent = lin1_State->Callback;
uint8_t lin_id_index = 0;//lin number index

switch (lin1_State->currentEventId)
{
case LIN_PID_OK:
/* Set timeout */
LIN_DRV_SetTimeoutCounter(INST_LIN1, TIMEOUT);

for(lin_id_index = 0; lin_id_index < MASTER_FRAME_COUNT; lin_id_index++)
{
if(g_lin_master_schedule_list_config[lin_id_index].ID == lin1_State->currentId)
{ /* If PID is FRAME_TX_RSP, salve node will receive data from master node */
if(g_lin_master_schedule_list_config[lin_id_index].Type == FRAME_TX_RSP)
{
/* Call to Send Frame DATA Function */
LIN_DRV_SendFrameData(INST_LIN1, g_lin_master_Pdu_Matrix[lin_id_index].buf, sizeof(g_lin_master_Pdu_Matrix[lin_id_index].buf));
break;
}
else if(g_lin_master_schedule_list_config[lin_id_index].Type == FRAME_RX_RSP )
{
/* Call to Receive Frame DATA Function */
//current_id_sn = lin_id_index;
//receive_new_frame_flag = 1;
LIN_DRV_ReceiveFrameData(INST_LIN1, g_lin_master_Pdu_Matrix[lin_id_index].buf, sizeof( g_lin_master_Pdu_Matrix[lin_id_index].buf));
break;
}

else
{

}
}
}
break;
/* If PID is FRAME_GO_TO_SLEEP, salve node will go to sleep mode */

case LIN_PID_ERROR:
/* Go to idle mode */
LIN_DRV_GoToSleepMode(INST_LIN1);
break;
case LIN_TX_COMPLETED:

case LIN_RX_COMPLETED:
/* Go to idle mode */
LIN_DRV_GotoIdleState(INST_LIN1);
break;
case LIN_CHECKSUM_ERROR:
case LIN_READBACK_ERROR:
case LIN_FRAME_ERROR:
case LIN_RECV_BREAK_FIELD_OK:
/* Set timeout */
LIN_DRV_SetTimeoutCounter(INST_LIN1, TIMEOUT);
break;
case LIN_WAKEUP_SIGNAL:
/* Set wakeup signal flag */
// wakeupSignalFlag = true;
break;
case LIN_SYNC_ERROR:
case LIN_BAUDRATE_ADJUSTED:
case LIN_NO_EVENT:
case LIN_SYNC_OK:
default:
/* do nothing */
break;
}
return callbackCurrent;
}

Outcomes