Hi,
I'm working on a recieve only CAN application that reads data from a sensor.
I planned to retrieve data with FLEXCAN_TransferReceiveNonBlocking but realized that status is constantly set to kStatus_FLEXCAN_RxBusy even with no sensor connected at all. A call to FLEXCAN_TransferHandleIRQ(EXAMPLE_CAN, &flexcanHandle); will invoke the callback with status set to kStatus_FLEXCAN_UnHandled. Something obviously seems to be wrong, does anyone have any hints how to best troubleshoot this? The callback looks like this:
static void flexcan_callback(CAN_Type *base, flexcan_handle_t *handle, status_t status, uint32_t result, void *userData)
{
switch (status)
{
/* Process FlexCAN Rx event. */
case kStatus_FLEXCAN_RxIdle:
if (RX_MESSAGE_BUFFER_NUM == result) {
rxComplete = true;
}
LOG_INFO("kStatus_FLEXCAN_RxIdle\r\n");
break;
case kStatus_FLEXCAN_UnHandled:
LOG_INFO("kStatus_FLEXCAN_UnHandled\r\n");
break;
default:
LOG_INFO("in flexcan_cb, status 0x%x(%d)\r\n",status,status);
}
}
Thanks!
Okay,
I see now that a call to FLEXCAN_TransferHandleIRQ(EXAMPLE_CAN, &flexcanHandle) triggers my callback with status set to kStatus_FLEXCAN_UnHandled and I also realized that a call to FLEXCAN_TransferReceiveNonBlocking() continously sets status to kStatus_FLEXCAN_RxBusy while mbState of my mailbox is set to 1 (kFLEXCAN_StateRxData) when I pause execution in the callback (that got called with status UnHandled).
My callback never gets called with kStatus_FLEXCAN_RxIdle even though I have something like (and I know that my sensor is continually sending out CAN frames at 250kb/s, I have a monitor connected to the same wires):
while (!rxComplete) {
(void)FLEXCAN_TransferReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer);
FLEXCAN_TransferHandleIRQ(EXAMPLE_CAN, &flexcanHandle);
}
where rxComplete is set true in the callback (when called with kStatus_FLEXCAN_RxIdle).