FlexCAN Call Back function for SDK

cancel
Showing results for 
Search instead for 
Did you mean: 

FlexCAN Call Back function for SDK

89 Views
Contributor I

Hello,

I find a problem about FlexCAN Call Back function. I don't understand why Rx status is kStatus_FLEXCAN_RxIdle rather than Rx Message Buffer full. This is the function.

/*!
* @brief FlexCAN Call Back function
*/
static void flexcan_callback(CAN_Type *base, flexcan_handle_t *handle, status_t status, uint32_t result, void *userData)
{
switch (status)
{
case kStatus_FLEXCAN_RxIdle:
if (RX_MESSAGE_BUFFER_NUM == result)
{
rxComplete = true;
}
break;

case kStatus_FLEXCAN_TxIdle:
if (TX_MESSAGE_BUFFER_NUM == result)
{
txComplete = true;
}
break;

default:
break;
}
}

Labels (1)
0 Kudos
2 Replies

10 Views
NXP TechSupport
NXP TechSupport

Hello ,

Hope you are doing well.

Flex Can works differently than what you might expect from UART for example. In Flex Can there is not a receive buffer full flag or tx buffer full flag that may be a source for an interrupt as there is in UART. 

Here, for Flex Can, you have to wait until there is no activity on the line. This is why the interrupt is generated when the line is idle. As you may see in the code once the line is idle it checks it the full message was received, if yes then it was successful and reception is complete if not then it leaves the if statement. 

You may also check chapter 44 of the reference manual, for other modes of operation that require the bus to be idle. In addition you may check how to use the CODE for matching and arbitration process in table 44-5.

Best Regards,

Sabina

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

0 Kudos

10 Views
Contributor I

Hello, Sabina,

Thank you for your help.

0 Kudos