Hi All,
I followed the provided SDK examples for CAN and I initialized the FlexCAN-Driver in my own example like shown below:
...
flexcan_config_t flexcanConfig;
flexcan_rx_mb_config_t mbConfig;
txIdentifier = 0x080;
rxIdentifier = 0x0A0;
FLEXCAN_GetDefaultConfig(&flexcanConfig);
flexcanConfig.baudRate = 500000U;
flexcanConfig.clkSrc = kFLEXCAN_ClkSrcPeri;
FLEXCAN_Init(PE900_CAN, &flexcanConfig, PE900_CAN_CLK_FREQ);
FLEXCAN_TransferCreateHandle(PE900_CAN, &flexcanHandle, flexcan_callback, NULL);
FLEXCAN_SetRxMbGlobalMask(PE900_CAN, FLEXCAN_RX_MB_STD_MASK(rxIdentifier, 0, 0));
mbConfig.format = kFLEXCAN_FrameFormatStandard;
mbConfig.type = kFLEXCAN_FrameTypeData;
mbConfig.id = FLEXCAN_ID_STD(rxIdentifier);
FLEXCAN_SetRxMbConfig(PE900_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);
FLEXCAN_SetTxMbConfig(PE900_CAN, TX_MESSAGE_BUFFER_NUM, true);
txframe.dataByte0 = 0x0F;
txframe.dataByte1 = 0xFF;
txframe.dataByte2 = 0x0F;
txframe.dataByte3 = 0xFF;
txframe.dataByte4 = 0x01;
rxXfer.mbIdx = RX_MESSAGE_BUFFER_NUM;
rxXfer.frame = &rxframe;
FLEXCAN_TransferReceiveNonBlocking(PE900_CAN, &flexcanHandle, &rxXfer);
...
I would expect that now only frames with CAN-ID 0x0A0 will be received but instead a lot of other ID's will be received all from 0xA0 to 0xBF. I think relevant steps are:
FLEXCAN_SetRxMbGlobalMask(PE900_CAN, FLEXCAN_RX_MB_STD_MASK(rxIdentifier, 0, 0));
and
mbConfig.id = FLEXCAN_ID_STD(rxIdentifier);
The second step is clear, nothing can be done wrongly here. But I would think the first step enables generally ID's but its usage is really clear to me. At this point the source code is also not documented well, no comment explains the meaning of rtr, ide. See:
#define FLEXCAN_RX_MB_STD_MASK(id, rtr, ide)
Fall back to the reference manual helps me also not really.
How to setup the flexCAN driver to receive messages only from one CAN-ID ?
Any help is welcome !