FlexCAN Call Back function for SDK

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FlexCAN Call Back function for SDK

854 次查看
1668834026
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;
}
}

标签 (1)
0 项奖励
2 回复数

775 次查看
Sabina_Bruce
NXP Employee
NXP Employee

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 项奖励

775 次查看
1668834026
Contributor I

Hello, Sabina,

Thank you for your help.

0 项奖励