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.
Solved! Go to Solution.
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
Hello.
I attached the code.
Im using MPC5748G with 1N81M mask so its NON ISO CAN FD.
Thanks, Ondřej.
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.
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
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