FlexCAN Fifo Interrupt which filter is the source?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FlexCAN Fifo Interrupt which filter is the source?

3,006 Views
maryellenmclaug
Contributor II

I am working with the MK22FX512AVLL12.  I was using the FlexCAN with the MB only.  Now I want to use the FIFO with an interrupt.  My question is simple. How do I know which acceptance filter caused the FIFO interrupt? Any help would be greatly appreciated

Tags (1)
0 Kudos
Reply
3 Replies

2,226 Views
GiselleLFreude
Contributor I

Hi, the way to tell which message ID triggered the interrupt is straight forward. Simply read the frame ID of the received frame in your RX handler. That would of course correspond to the filter that triggered the interrupt.

//example

rxFifo.frame = & rxFrame;
FLEXCAN_TransferReceiveFifoNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxFifo);
/* Wait until Rx MB full. */
while (!rxComplete)
{
     vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(50));
};

rxComplete = false;

 // Process received message
 m.cob_id = FLEXCAN_ID_STD_INV(rxFrame.id);
 
//Now that you have your frame ID, that should be what you need
0 Kudos
Reply

2,705 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Mary:

I  would suggest you check the Interrupt Flags 1 Register CANx_IFLAG1.

This flag register contains one interrupt flag bit per buffer. Each successful transmission or reception sets the corresponding IFAG1 bit.

Please refer to K22 reference manual for more details.

Regards

Daniel

0 Kudos
Reply

2,705 Views
maryellenmclaug
Contributor II

The BUF7I to BUF5I flags are used to represent FIFO interrupts when the Rx FIFO
is enabled, so the first received CAN message will set the BUF5I flag in IFLAG1, but that won't tell me which filter was matched to cause the interrupt. I want to know which ID was hit.  I thought CANx_RXFIR would have the Identifier Acceptance Filter Hit Indicator that would tell me which Identifier Acceptance Filter was hit by the received message but it is always zero. 

Each ID to match on the receive is set as follows 

FLEXCAN_SetRxIndividualMask(CAN0,currentFifo, FLEXCAN_RX_MB_STD_MASK(0x71F, 0, 0));
rxFifoFilter[currentFifo++ ] = FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(cob_id, rtr, 0);

THen the full table with the filters is configured as follows, to get the interrupt on the match 

rxFifoConfig.idFilterTable = rxFifoFilter;
rxFifoConfig.idFilterType = kFLEXCAN_RxFifoFilterTypeA;
rxFifoConfig.idFilterNum = currentFifo;//sizeof(rxFifoFilter) / sizeof(rxFifoFilter[0]);
rxFifoConfig.priority = kFLEXCAN_RxFifoPrioHigh;
FLEXCAN_SetRxFifoGlobalMask(CAN0,FLEXCAN_RX_MB_STD_MASK(0x71F, 0, 0));
FLEXCAN_SetRxFifoConfig(CAN0, &rxFifoConfig, true);
/* Start receive data through Rx Message Buffer. */

FLEXCAN_TransferReceiveFifoNonBlocking(CAN0, &flexcanHandle, &FifoFrame);

FLEXCAN_EnableMbInterrupts(CAN0,kFLEXCAN_RxFifoFrameAvlFlag);

What am I missing?

0 Kudos
Reply