AnsweredAssumed Answered

FlexCAN Message Buffer lock and message processing problem

Question asked by Ondřej Urban on Feb 6, 2019
Latest reply on Feb 7, 2019 by Ondřej Urban



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.