S32K344 FlexCAN IP with Legacy RxFIFO and DMA

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K344 FlexCAN IP with Legacy RxFIFO and DMA

Jump to solution
1,088 Views
nhyjq2000
Contributor I

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?

Attachment is whole code.
 

May I know what's wrong? Thank you.

1.jpg2.jpg3.jpg4.jpg

0 Kudos
Reply
1 Solution
1,058 Views
PetrS
NXP TechSupport
NXP TechSupport

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 

View solution in original post

0 Kudos
Reply
5 Replies
1,072 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

attached is modified project with working DMA RXFIFO reading.
In your setup std ID range 0x50-0x5F is received into MB9 except of std ID 0x55 which is received into RXFIFO.

Hope it helps.

BR, Petr

0 Kudos
Reply
1,064 Views
nhyjq2000
Contributor I

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.

0 Kudos
Reply
1,059 Views
PetrS
NXP TechSupport
NXP TechSupport

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 

0 Kudos
Reply
1,045 Views
nhyjq2000
Contributor I

Thank you Petr, It works as I expect, Thanks again.

Have a nice day.

0 Kudos
Reply
286 Views
hyj123456789
Contributor I

我也是配置了RX_FIFO,can可以接收,但是发不出去,楼主遇到这个问题么

0 Kudos
Reply