FlexCAN Message Buffer lock and message processing problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

FlexCAN Message Buffer lock and message processing problem

ソリューションへジャンプ
738件の閲覧回数
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 解決策
594件の閲覧回数
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 返答(返信)
595件の閲覧回数
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 件の賞賛
594件の閲覧回数
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 件の賞賛