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
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
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
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?