S32K142 CAN0 如何开启自动重发及发送丢失问题?

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

S32K142 CAN0 如何开启自动重发及发送丢失问题?

1,142 Views
june_android
Contributor I

在我的实际使用中,每个发送邮箱只发送一个ID的can报文。

不知道什么原因,可能会导致某个邮箱的发送报文不能发出,发送报文丢失。

只有重新初始化can之后,才可以发出丢失的报文。

另一个问题,实际使用中,总线符合很高,可能会出现发送超时失败的情况,can的发送如何开启自动重发功能,现在我只能通过代码软件来实现发送失败后再次发送。

 

 

/* Set information about the data to be sent
 *  - 1 byte in length
 *  - Standard message ID
 *  - Bit rate switch enabled to use a different bitrate for the data segment
 *  - Flexible data rate enabled
 *  - Use zeros for FD padding
 */
flexcan_data_info_t dataInfo =
    {
        .data_length = snedMsg.dataLen,
        .msg_id_type = FLEXCAN_MSG_ID_STD,
        .enable_brs = false,
        .fd_enable = false,
        .fd_padding = 0U,
        .is_remote = false}
if (((CAN0->RAMn[snedMsg.mb_id * 4] >> 24) & 0x0000000f) == 0x08)
{
    canCom1_State.mbs[snedMsg.mb_id].state = FLEXCAN_MB_IDLE;
}
/* Configure TX message buffer with index TX_MSG_ID and TX_MAILBOX*/
if (FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, snedMsg.mb_id, &dataInfo, snedMsg.msgId) != STATUS_SUCCESS)
{
    return;
}
/* Execute send blocking */
// FLEXCAN_DRV_Send(INST_CANCOM1, snedMsg.mb_id, &dataInfo, snedMsg.msgId, &snedMsg.data[0]);
uint8_t i = 0;
status_t ss;
do
{
    ss = FLEXCAN_DRV_SendBlocking(INST_CANCOM1, snedMsg.mb_id, &dataInfo, snedMsg.msgId, &snedMsg.data[0], 1);
    if (busError > 0)
    {
        break;
    }
    i++;
    if (i >= 5)
    {
        break;
    }
} while (ss != STATUS_SUCCESS);

 

 

0 Kudos
Reply
1 Reply

1,126 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

based on given code snippet, I can recommend to do not touch internal status variable and increase timeout for send blocking function. This blocking function performs abort for given MB if timeout is detected, thus rely on a value returned by this function and for timeout send message again.

BR, Petr 

0 Kudos
Reply