Hello NXP,
I need your help, please. My problem is receiving several CAN messages PERIODICALLY without filtering. It means, for example, i have 10 CAN messages with different period 50ms, 100ms, 500ms. If I take, for example, CAN ID = 0x101 and I receive with filtering, i receive periodically, but if I receive without filtering, this CAN message is received non periodically.
This can indeed happen if you don't set the mask for each MBs, which is not the correct way to set it.
In order to meet your design requirements, you can refer to this demo
https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753
Chapter:4.2.Set the Mask Type to Individual Mask Type.
This can indeed happen if you don't set the mask for each MBs, which is not the correct way to set it.
In order to meet your design requirements, you can refer to this demo
https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753
Chapter:4.2.Set the Mask Type to Individual Mask Type.
Thank you for your response,
I don't understand about
4.1.Set the Mask Type to Global Mask Type.
In this case, we can only receive the messages which ID from 0x300~0x37F and 0x400~0x47F.
but what if i want to receive for example 0x001~0x399 0x480~0x7FF. The idea is to identify the IDs and periods of the receiving CAN messages in a range 0x001~0x7FF.
If you want to receive all IDs, you can set the mask to all 0
like this?
FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
FLEXCAN_DRV_SetRxMaskType(INST_CANCOM1, FLEXCAN_RX_MASK_GLOBAL);
FLEXCAN_DRV_SetRxMbGlobalMask(INST_CANCOM1, FLEXCAN_MSG_ID_STD, 0);
flexcan_data_info_t dataInfo =
{
.data_length = 8U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,
.fd_padding = 0U,
.is_remote = false
};
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1,RX_MAILBOX, &dataInfo, 0x7FF);
Yes, all ID messages can be received in this way, but frame loss will occur if the speed is too fast, and this is not the correct way to use it. The recommended approach is to set one MB for each ID and set the mask value to all 1s.
The idea is receive several CAN messages, and identify IDs of messages. If i want receive 40 messages, but there are just 32 MB, so I can't set one MB for each ID, with my understanding.
hello @Senlent ,
Can you clarify, please, about your last message
The recommended approach is to set one MB for each ID and set the mask value to all 1s.
for example:
FLEXCAN_DRV_SetRxMaskType(INST_CANCOM1,FLEXCAN_RX_MASK_INDIVIDUAL);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, mb_idx_1, &dataInfo, msg_id_1);
FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1,FLEXCAN_MSG_ID_STD,mb_idx_1,0xFFFFFFFF);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, mb_idx_1, &dataInfo, msg_id_2);
FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1,FLEXCAN_MSG_ID_STD,mb_idx_2,0xFFFFFFFF);
...............
Hello @Senlent
Thank you very much for your answer.
FLEXCAN_DRV_SetRxMaskType(INST_CANCOM1,FLEXCAN_RX_MASK_INDIVIDUAL); FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, mb_idx_1, &dataInfo, msg_id_1); FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1,FLEXCAN_MSG_ID_STD,mb_idx_1,0xFFFFFFFF); FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, mb_idx_1, &dataInfo, msg_id_2); FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1,FLEXCAN_MSG_ID_STD,mb_idx_2,0xFFFFFFFF);
this configuration is for receiving CAN messages with filtering, but I need receiving without filtering.
We've discussed filtering and not filtering, I don't know that your problem is not solved yet.
You can send me your demo, I will reproduce this problem first, and I will think about whether there is any way to improve it.
I read your code, there are many problems, I can not help you to modify directly. I suggest you refer to the routine of interrupt sending and receiving, you can set the mask to all 0 (if you don't want to set the mask)
You can use MB or FIFO to interrupt receiving and sending, I suggest you read the demo in my previous answer