FLEXCan RxIdle triggers on FLEXCAN_TransferSendBlocking

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

FLEXCan RxIdle triggers on FLEXCAN_TransferSendBlocking

跳至解决方案
615 次查看
_bjs
Contributor III

Hello NXP Community,

I have a RT1050 Board and i am running the FlexCan_Interrupt_Transfer example.

This example is either transmitting or receiving, but i have modified this software to send blocking every 1 second, and receive any CAN ID packet.


//callback
static FLEXCAN_CALLBACK(flexcan_callback)
{
switch (status)
{
case kStatus_FLEXCAN_RxIdle:
if (RX_MESSAGE_BUFFER_NUM == result)
{
uint32_t id = rx_frame.id >> CAN_ID_STD_SHIFT;
PRINTF("CAN BUS DATA RECEIVED !?!? [0x%X] , txIdentifier = [0x%X].\r\n", id, txIdentifier);
rxXfer.frame = &rx_frame;
(void)FLEXCAN_TransferReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer);
}
break;
default:
break;
}
}
//initialization (for accepting any RX ID)
...
/* Set Rx Masking mechanism. */
//rxIdentifier = 0;
FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, FLEXCAN_RX_MB_STD_MASK(rxIdentifier, 0, 0));
//once every second
...
tx_frame.id = FLEXCAN_ID_STD(txIdentifier);
tx_frame.format = (uint8_t)kFLEXCAN_FrameFormatStandard;
tx_frame.type = (uint8_t)kFLEXCAN_FrameTypeData;
tx_frame.length = (uint8_t)DLC;
txXfer.mbIdx = (uint8_t)TX_MESSAGE_BUFFER_NUM;

txXfer.frame = &tx_frame;
FLEXCAN_TransferSendBlocking(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, &tx_frame);
//the problem
15:00:01.554> CAN BUS DATA RECEIVED !?!? [0x123] , txIdentifier = [0x321]. //<! correct
15:00:01.999> CAN BUS DATA RECEIVED !?!? [0x321] , txIdentifier = [0x321]. //<! Incorrect
15:00:02.548> CAN BUS DATA RECEIVED !?!? [0x124] , txIdentifier = [0x321]. //<! correct
15:00:03.050> CAN BUS DATA RECEIVED !?!? [0x321] , txIdentifier = [0x321]. //<! Incorrect
15:00:03.554> CAN BUS DATA RECEIVED !?!? [0x125] , txIdentifier = [0x321]. //<! correct
15:00:04.059> CAN BUS DATA RECEIVED !?!? [0x321] , txIdentifier = [0x321]. //<! Incorrect


I will filter the received ID from the callback, but i prefer the callback to trigger only on actually received packets. 

What am I doing wrong?

Thank you!

 

标签 (1)
标记 (1)
0 项奖励
1 解答
602 次查看
_bjs
Contributor III

found a solution here:
https://community.nxp.com/t5/S32K/For-FLEXCAN-I-use-the-receive-interrupt-enable-but-send/td-p/71450...

WARNING:
I have printed the values in the IMASK1 register. these were 0x0.
After i set the IMASK1 to 0x400 (ENABLING TX mailbox 10), the Transfer complete successful interrupt mailbox is not causing RXIDle callback.
The API macro this does this is called:

FLEXCAN_EnableMbInterrupts(EXAMPLE_CAN, 1UL << TX_MESSAGE_BUFFER_NUM); //<! used for disabling, 

在原帖中查看解决方案

0 项奖励
1 回复
603 次查看
_bjs
Contributor III

found a solution here:
https://community.nxp.com/t5/S32K/For-FLEXCAN-I-use-the-receive-interrupt-enable-but-send/td-p/71450...

WARNING:
I have printed the values in the IMASK1 register. these were 0x0.
After i set the IMASK1 to 0x400 (ENABLING TX mailbox 10), the Transfer complete successful interrupt mailbox is not causing RXIDle callback.
The API macro this does this is called:

FLEXCAN_EnableMbInterrupts(EXAMPLE_CAN, 1UL << TX_MESSAGE_BUFFER_NUM); //<! used for disabling, 

0 项奖励