s32k144 can1 can2 FLEXCAN DMA FIFO Cannot receive data!

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

s32k144 can1 can2 FLEXCAN DMA FIFO Cannot receive data!

1,020 Views
nmyzer
Contributor II

Picture1 :  Set flexcan1 to fifo receive mode and dma send mode

nmyzer_1-1709108959286.png

 

Picture 2 Set flexcan2 to fifo receive mode and dma send mode

nmyzer_0-1709108939478.png

Picture 3

nmyzer_2-1709109079335.png

Picture 4

nmyzer_3-1709109113896.png

But when I downloaded the program to the chip, when can data come , it got stuck in the image below。

Picture 5  Where the program stuck

nmyzer_4-1709109215488.png

However, when I changed the send mode to interrupt mode, the program could run, but when sending multiple CAN data, some CAN data frames would be missed. Unless I insert a 1ms delay function after each CAN send data frame.(Because I set up 16 filters, MB0 to 5 is occupied by data frames, MB6 to 9 is occupied by filters, so I use the sending mailbox MB10 to MB15)

I would like to know why FLEXCAN data frames cannot be sent in dma mode, please kindly ask NXP technical staff to help answer it, thank you!

 

Tags (2)
0 Kudos
Reply
6 Replies

967 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

could you please specify the SDK version you are using? Or better share full project you have so we can check and test. How modules are used, you do communication between CAN1 and CAN2 or are you somehow connected to other nodes?

Did you meant you cannot send message using TX MBs when DMA is used to read out RXFIFO? There shouldn't be issue with this. YOu can refer to below example, 
https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K144-FlexCAN-RXFIFO-DMA-S32DS-ARM-2018-R...

BR, Petr

0 Kudos
Reply

955 Views
nmyzer
Contributor II

Hi:

First, the SDK version I'm using is 3.0.0;

Second, I used CAN1 and CAN2 interfaces of a control circuit board to communicate with multiple external devices at the same time, rather than directly connecting CAN1 and CAN2.

Third, what I said above about the failure is wrong, the reality is that when the program is running, the data can be sent from my control board (which I observed with PEAKCAN), but once the external device run and starts sending data, my board starts receiving data. The program gets stuck inside the FLEXCAN_IRQHandler's while((flag_req&1u) == 0U);

Look forward to your professional answer, thank you

0 Kudos
Reply

953 Views
nmyzer
Contributor II

picture 6:can1 callback function,similar to can2, but with different markup variables。

nmyzer_0-1709208363905.png

picture 7:The task handler function that runs in the main loop

nmyzer_1-1709208422309.png

 

 

0 Kudos
Reply

855 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if remember well there was some issue in S32PA RTM 3.0 regards desynchronization of MB status with the IFLAGs flags.

The solution was to apply a check at the end of ISR function check in FLEXCAN_IRQHandler:

        if (FLEXCAN_GetMsgBuffIntStatusFlag(base, mb_idx) != 0U)

        {

            /* In case of desynchronized status of the MB to avoid trapping in ISR

             * clear the MB flag */

            FLEXCAN_ClearMsgBuffIntStatusFlag(base, mb_idx);

       }

PetrS_0-1709905204016.png

 

This would be fixed in SDK 4.0.x. Moreover SDK30 is no longer maintained, I think, so it is advisable to use latest one, or move to RTD driver.

BR, Petr

0 Kudos
Reply

853 Views
nmyzer
Contributor II

Thank you for your reply. After a week of code debugging, the above problems have been solved;

But here's a new problem:

When my target board sends only one frame of data with a period of 10 seconds, the software shows that the receiving time period is very small error.

nmyzer_0-1709986450273.png

When my target board sent multiple frames of different periods of data, the original 10-second cycle of CAN data frame receiving time error became very large, and the entire program running slower, I roughly calculated that the program running 2 minutes of error is 4 seconds.

nmyzer_1-1709986801470.png

Is there a solution?

 

 

0 Kudos
Reply

809 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

do you use more MBs for transmitting? If yes, then what is a priority mechanism used? Check chapter 55.3.3 Arbitration process

BR, Petr

0 Kudos
Reply