We were using the automatic-retransmit, however, it would send an unacknowledged message endlessly. We noticed this when attaching a Peak branded CAN tool at the link. Because it interferes with our power management approach (not to mention the endless re-transmit), DAR (disable auto transmit) is now selected.
Now we desire to handle TX message retries during transmission of the next message (taking the arbitration loss status and re-requesting the scheduler to attempt again.) What I find is that the “newdat” flag is only being cleared at a very low rate (<95% of the time.) According to the TRM a successful transmission will also clear the newdat flag (in addition to the TxReq flag). It might be helpful to know, the very same system which returns these arbitration loss indications seems to communicate flawlessly.
Anyways, here is the function we have which is returning the “bad status”, perhaps you can help us out. Thanks !! Frank
volatile bool msgbox_tx_failed = false;
bool mcal_can_transmit_ready(mcal_can_message_t *can_message)
{
mcal_can_base_t *can_reg_n = NULL;
uint32_t tx_status_index;
uint32_t tx_busy_bit;
uint32_t msgbox_newdat_bit;
mcal_can_link_enum_t can_link;
bool can_tx_ready = false;
msgbox_tx_failed = false;
// Verify CAN device exists
can_link = can_message->message_route.can_link;
if (can_link >= MCAL_NUM_CAN_CHANNELS)
{
mcal_can_status.invalid_channel_req = true;
}
else
{
can_reg_n = mcal_can_register_list[ can_link ];
tx_status_index = (can_message->message_route.can_stream - 1u) >> 5u;
tx_busy_bit = 1u << ((can_message->message_route.can_stream - 1u) & 0x1f);
msgbox_newdat_bit = 1u << ((can_message->message_route.can_stream - 1u) & 0x1f);
// Verify valid mailbox
if ((can_message->message_route.can_stream >= MAX_VALID_MAILBOX) ||
(can_message->message_route.can_stream == 0))
{
mcal_can_status.invalid_mailbox_id = true;
}
else if ((can_reg_n->txrq[tx_status_index] & tx_busy_bit) == 0u)
{
can_tx_ready = true;
if ((can_reg_n->msgval[tx_status_index] & msgbox_newdat_bit) != 0u)
{
msgbox_tx_failed = true;
}
}
}
return can_tx_ready;
}