FlexCAN Message Buffer lock and message processing problem

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

FlexCAN Message Buffer lock and message processing problem

Jump to solution
708 Views
ondrau2
Contributor II

Hello.

I have written a simple CAN FD software that sends and receives data in loopback mode on MPC5748G.

All worked properly, untill I replaced Rx message processing from interrupt routine to main loop.

When interrupt occurs, the interrupt flag is cleared (by writing appropriate bit in CAN_0.IFLAG1.R), and the MB is locked by reading MBs Control and Status word (temp = *CAN0_MB_CS_arr[i]; where CAN0_MB_CS_arr is array with MB CS adresses). Flag signalizing message reception is then set.

In main loop, the MB processing function is called. This function reads CODE, DLC, ID, TimeStamp, and data.

Then the lock is released by reading timer temp = CAN_0.TIMER.R.

The MBs CODE is 2, ID and DLC is correct. However the received data are all zeros.

When similar MB processing function is placed in interrupt handler, the data are received correctly.

Am I doing something wrong?

Best regards, Ondřej.

0 Kudos
1 Solution
564 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Ondřej,

it should not behave this way, the MB is keeping received data until it is overwritten by user or by the module (when new message is moved-in). So it does not matter if MB is fully read within ISR or not.

Do you read MB on proper addresses still? 

BR, Petr

View solution in original post

0 Kudos
2 Replies
565 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Ondřej,

it should not behave this way, the MB is keeping received data until it is overwritten by user or by the module (when new message is moved-in). So it does not matter if MB is fully read within ISR or not.

Do you read MB on proper addresses still? 

BR, Petr

0 Kudos
564 Views
ondrau2
Contributor II

Hello.

Thank you for advice!

I once more checked adressing of the MBs and found a bug that did not appear when the message processing was done directly in in ISR.

It works fine now. Thank you.

Best regards, Ondřej.

0 Kudos