FlexCAN Message Buffer initialization

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

FlexCAN Message Buffer initialization

ソリューションへジャンプ
2,819件の閲覧回数
ondrau2
Contributor II

Hello.

Im using FlexCAN with CAN FD on MPC5748G.

Im still a little confused about proper initialization of MBs.

Lets say I want a simple demo application, that uses loopback mode to transmit and receive one ID message.

Then I have to configure one Rx MB by setting its ID filter and mask and also CODE to 0x04 (empty).

Second MB is used for transmission, so I simply write 0 to its CS register.

When I want to send a message, I use Tx MB - check its state and write ID, data, and so on... and by writing 0x0C to CODE, the MB enters the arbitration process and the message is transmitted.

Am I right?

Problem is that when I do the steps above, the Tx MB is not sent - code of the MB still remains 0x0C.

(Rx interrupt is only generated when I use the Rx MB - then, after writing 0x0C to CODE field which is then changed to 0x08. But I guess its simply because I directly modify the Rx MB).

Did I miss something, or is the mistake somewhere else in my code?

Thank you, Ondřej.

0 件の賞賛
返信
1 解決策
2,536件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, for different payloads the MB memory offset varies. The chapter  43.4.42 FlexCAN message buffer memory map of the RM summarizes this in Tables 43-13 to 43-16.

BR, Petr 

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
2,536件の閲覧回数
ondrau2
Contributor II

Hello.

I attached the code.

Im using MPC5748G with 1N81M mask so its NON ISO CAN FD.

Thanks, Ondřej.

0 件の賞賛
返信
2,536件の閲覧回数
ondrau2
Contributor II

Hello again.

After some debugging I finally found the reason why my code wouldn't work.

It was because MBs memory offsets. I use 64 byte payload per MB (MBDSRn=11), so the message buffers had different offset than when using 8 byte payload. (It appeared OK during debugging, but I actually didn't write the CODE and other fields to proper addresses).

Best regards, Ondřej. 

0 件の賞賛
返信
2,537件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, for different payloads the MB memory offset varies. The chapter  43.4.42 FlexCAN message buffer memory map of the RM summarizes this in Tables 43-13 to 43-16.

BR, Petr 

0 件の賞賛
返信
2,536件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi Ondřej,

your understanding of the MBs initialization is correct. 

However the behavior you see is strange. If the TX code stays 0xC and TX MB flag is not set it means message was not sent successfully. This could be due to ACK error. But if module is set to loopback mode (CTRL1[LPB]=1), ACK is ignored, and message is always sent, regardless if there is prepared RX MB or not.

So hard to say, you did not share your code.

BR, Petr

0 件の賞賛
返信