I am having a hard time getting the FlexCAN module to filter out messages that do not match the programmed ID in the mailbox.
In my example I am using extended CAN IDs and the RXMGMASK register as the filter.
I set the following registers for reception:
- RXMGMASK to 0x1FFFFFFF
- MB.ID = CAN_ID_EXT(0x1A5)
- MB.CS[CODE] = 0x4
- MB.CS[IDE] = 1
I am using the Kvaser CAN King software to send messages to the UUT.
I would expect only messages with CAN ID of 0x1A5 to be received, however all CAN messages are received regardless of the ID value.
I have read the matching process section of the reference manual a dozen times now and do not understand what I am missing.
Any help would be appreciated.
Hi,
First of all, can you tell us the part number you are using?
Regarding your issue of FlexCAN receiver, you can receive all packet no matter what the ID is, pls check if the CAN_MCR[IRMQ] bit is cleared. when the bit is cleared, the mailbox filter is valid.
Hope it can help you
BR
XiangJun Rong
Hello,
Thanks for the response.
I am using the MKE18F512VLH16 processor.
I verified in the debugger that the CAN_MCR[IRMQ] bit is negated when I am receiving messages.
I just tried using the individual mask registers and set the CAN_MCR[IRMQ] to 1, and that actually worked. I am only using one mailbox to receive messages, so this will work for me.
Outside of negating the CAN_MCR[IRMQ] bit, and setting the CAN_RXMGMASK to 0x1FFF_FFFF, is there any other reason why the filtering wouldn't work? Just don't understand why the global one didn't work and the individual one did. They seem to work the same.
Hi,
You use a global mask register, but the global mask mechanism does not function, you can receive packet with any IID, am I right?
BR
XiangJun Rong
I am using mailbox 0 to receive messages.
I was able to get the filtering to work using the individual mask register (CAN_RXIMR0 = 0x1FFF_FFFF and CAN_MCR[IRMQ] = 1).
I was not able to get the filtering to work using the global mask register (CAN_RXGMGMASK = 0x1FFF_FFFF and CAN_MCR[IRMQ] = 0).
Does the global mask register (RXMGMASK) not work the same as the individual mask register (RXIMRn)? I think I am misunderstanding how the global mask works.
Hi,
Sorry for misunderstanding you.
Regarding the CANx_RXMGMASK,CANx_RX14MASK and CANx_RX15MASK, the RM says that they are for legacy application support.
I have checked the original version of FlexCAN, the original version of FlexCAN only have CANx_RXMGMASK,CANx_RX14MASK and CANx_RX15MASK, but does not have CANx_RXIMRx register group.
So I think it is okay to configure the CANx_RXIMRx register group for each mailbox, the CANx_RXMGMASK,CANx_RX14MASK and CANx_RX15MASK are useless, they are provided for legacy application support.
BTW, the MC56F83xx use the original FlexCAN.
https://www.nxp.com.cn/docs/en/user-guide/MC56F8300UM.pdf
Hope it can help you
BR
XiangJun Rong