FlexCAN Message Buffer lock and message processing problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

FlexCAN Message Buffer lock and message processing problem

跳至解决方案
745 次查看
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 项奖励
1 解答
601 次查看
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 项奖励
2 回复数
602 次查看
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 项奖励
601 次查看
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 项奖励