I encounted one problem for CAN message transmitting,in the case that the sending message number is large,the message can't transmit successfully.
I do it like this:
configure one mailbox and then transmit the message using these two functions:
FLEXCAN_DRV_ConfigTxMb(instance, mailbox, &dataInfo, messageId);
FLEXCAN_DRV_Send(instance, mailbox, &dataInfo, messageId, data);
since the transmiting message number is more than 100,so I have to re-use the mailbox. I found some transmiting will be failure if one mailbox is used a second time,even there is some time gap to re-use the same mailbox.
in order to avoid the failure of re-use same mailbox,which falg can indicate the transmiting finished? then I can use this flag for checking before using the same mailbox again.
you can use below function
It returns STATUS_SUCCESS if transmission is finished for given MB otherwise you get STATUS_BUSY.
if not using within while loop I see no reason why this function should block the code.
Another option could be installing the Callback function and use FLEXCAN_EVENT_TX_COMPLETE event to indicate message was successfully transmitted.
void flexcan0_Callback(uint8_t instance, flexcan_event_type_t eventType, uint32_t mb_num,
/* Install callback function */
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1, flexcan0_Callback, NULL);
the message sending function is not called in while loop, it's called by freeRTOS.
but I checked the status,usually the status is busy and coding is blocked there for a long time,especially in the condition that high MCU load and a large number of messages transfering in CAN bus.
which reasons could cause the mailbox in busy status? is it possible that the message is trying to transmit continuously after transmitting failure?
maybe a message is not transmitted successfully without error and so driver interrupt is not called and driver's MB status is not changed. If error is detected during transmission the message is re-transmitted again.
You can check ECR/ESR1 registers for errors. Also chack flag status in IFLAGx registers and if interrupt is enabled for the MB in IMASKx register.