FLEXCan RxIdle triggers on FLEXCAN_TransferSendBlocking

cancel
Showing results for 
Search instead for 
Did you mean: 

FLEXCan RxIdle triggers on FLEXCAN_TransferSendBlocking

Jump to solution
231 Views
_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!

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
218 Views
_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, 

View solution in original post

0 Kudos
1 Reply
219 Views
_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 Kudos