Hello,
I'm trying to communicate with my PC CAN tools. I choose Legacy FIFO because I plan to use multi FlexCAN channels not only FlexCAN0.
1. After completed configuration, S32K344 can receive data package succesfully from PC CAN tools when I invoke FlexCAN_Ip_Receive, but not work if I invoked FlexCAN_Ip_RxFifo and no FLEXCAN_EVENT_RXFIFO_COMPLETE event triggered in callback function.
2. I want to send data package with MSG ID from 0x50 to 0x5F, but in fact almost All ID send succesfully except 0x55 with FlexCAN_Ip_Receive. Is there something wrong in my mask or filter config?
3. About the number of message buffer transfer in DMA. Is there a best practice value?
May I know what's wrong? Thank you.
Solved! Go to Solution.
Hi,
then you need to change configuration little bit. Also you should config all items in filter ID table, otherwise other IDs can be received as well, depending on item value and corresponding mask register.
Your new setting could be
const Flexcan_Ip_IdTableType CAN0_FIFO_IdFilterTable[8] = {
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,}
};
FlexCAN_Ip_SetRxMaskType_Privileged(INST_FLEXCAN_0,FLEXCAN_RX_MASK_INDIVIDUAL);
FlexCAN_Ip_ConfigRxFifo_Privileged(INST_FLEXCAN_0,FLEXCAN_RX_FIFO_ID_FORMAT_A , &CAN0_FIFO_IdFilterTable[0]);
FlexCAN_Ip_SetRxIndividualMask(INST_FLEXCAN_0, 0, 0x7F0<<19); // mask for first ID in Filter table
FlexCAN_Ip_SetRxIndividualMask(INST_FLEXCAN_0, RX_MB_IDX, 0x7FF<<18); // mask for MB9 (RX_MB_IDX)
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX, &rx_info, 0x50u);
This way RXFIFO receives ID range 0x50 to 0x5F.
No message will come into MB9 as it has same ID to be received as RXFIFO and RXFIFO is scanned first by default.
BR, Petr
Hello Petr,
Thank you for your help.
Running the modified project program, ID 0x55 is recevied in FLEXCAN_EVENT_DMA_COMPLETE event, but just only 0x55.
I expect that all of ID range 0x50-0x5F can send into RxFIFO, how should I set filter and mask? or any mistake in my code?
const Flexcan_Ip_IdTableType CAN0_FIFO_IdFilterTable[8] = {{
.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,
}
};
FlexCAN_Ip_SetRxMaskType_Privileged(INST_FLEXCAN_0,FLEXCAN_RX_MASK_INDIVIDUAL);
FlexCAN_Ip_ConfigRxFifo_Privileged(INST_FLEXCAN_0,FLEXCAN_RX_FIFO_ID_FORMAT_A , &CAN0_FIFO_IdFilterTable[0]);
FlexCAN_Ip_SetRxIndividualMask(INST_FLEXCAN_0, RX_MB_IDX, 0x7F0<<18);
FlexCAN_Ip_SetStartMode(INST_FLEXCAN_0);
Best regards.
Hi,
then you need to change configuration little bit. Also you should config all items in filter ID table, otherwise other IDs can be received as well, depending on item value and corresponding mask register.
Your new setting could be
const Flexcan_Ip_IdTableType CAN0_FIFO_IdFilterTable[8] = {
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,},
{.id = 0x55u,.isRemoteFrame = false,.isExtendedFrame = false,}
};
FlexCAN_Ip_SetRxMaskType_Privileged(INST_FLEXCAN_0,FLEXCAN_RX_MASK_INDIVIDUAL);
FlexCAN_Ip_ConfigRxFifo_Privileged(INST_FLEXCAN_0,FLEXCAN_RX_FIFO_ID_FORMAT_A , &CAN0_FIFO_IdFilterTable[0]);
FlexCAN_Ip_SetRxIndividualMask(INST_FLEXCAN_0, 0, 0x7F0<<19); // mask for first ID in Filter table
FlexCAN_Ip_SetRxIndividualMask(INST_FLEXCAN_0, RX_MB_IDX, 0x7FF<<18); // mask for MB9 (RX_MB_IDX)
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_0, RX_MB_IDX, &rx_info, 0x50u);
This way RXFIFO receives ID range 0x50 to 0x5F.
No message will come into MB9 as it has same ID to be received as RXFIFO and RXFIFO is scanned first by default.
BR, Petr
In addition, I found that when the mask configuration is 0x7FF<<18 or 0x7FF<<19, or even 0x7FF<<20, both 0x455 and 0x55 can be received by rxFifo. Whycan 0x455 be received?
Why is the configuration of the mask here not 0x7F0<<18, but 0x7F0<<19?
Thank you Petr, It works as I expect, Thanks again.
Have a nice day.
我也是配置了RX_FIFO,can可以接收,但是发不出去,楼主遇到这个问题么