Skip to main content
GS1
Senior III
December 29, 2020
Solved

How to correctly set up FDCAN Message RAM Start Addresses?

  • December 29, 2020
  • 1 reply
  • 4375 views

How do I have to set the configuration of the FDCAN Message RAM Start Adresses correctly in order to use 2 CANFDs simultaneously?

Is there an example which shows a correct initialisation? The default samples initialize all start Adresses to 0, but this leads to Message corruption!

Here my sample code:

Would this be correct?

   if (nCan == CAN0)

   {

      phCan->Instance = FDCAN1;

      uCANOffset = 0;

   }

   else

   {

      phCan->Instance = FDCAN2;

      uCANOffset = 1024;

   }

   phCan->msgRam.StandardFilterSA = 0;

   phCan->msgRam.ExtendedFilterSA = 0;

   // Start-Adressen für Message-RAM:

   phCan->msgRam.RxFIFO0SA = 0+uCANOffset;

   phCan->msgRam.RxFIFO1SA = 512+ uCANOffset;

   phCan->msgRam.RxBufferSA = 1024;

   phCan->msgRam.TxEventFIFOSA = 0;

   phCan->msgRam.TxBufferSA = 0;

   phCan->msgRam.TxFIFOQSA = 0;

   phCan->msgRam.TTMemorySA = 0;

   phCan->msgRam.EndAddress =0;

   phCan->ErrorCode = 0;

Thank you for any help.

This topic has been closed for replies.
Best answer by GS1

OK, I got it:

The correct RAM initialisation is done as follows:

if (nCan == CAN0)

{

      phCan->Instance = FDCAN1;

      uCANOffset = 0;

}

else

{

      phCan->Instance = FDCAN2;

      uCANOffset = 1024;

}

   phCan->Init.MessageRAMOffset = uCANOffset;

   ...

   phCan->msgRam.StandardFilterSA = 0;

   phCan->msgRam.ExtendedFilterSA = 0;

   // Start-Adressen für Message-RAM:

   phCan->msgRam.RxFIFO0SA = 0;

   phCan->msgRam.RxFIFO1SA = 0;

   phCan->msgRam.RxBufferSA = 0;

   phCan->msgRam.TxEventFIFOSA = 0;

   phCan->msgRam.TxBufferSA = 0;

   phCan->msgRam.TxFIFOQSA = 0;

   phCan->msgRam.TTMemorySA = 0;

   phCan->msgRam.EndAddress = 0;

   phCan->ErrorCode = 0;

This ensures that both CANs can be used without conflict in the RAM for receiving messages.

Hope this helps others for initialising 2 x FDCAN-Bus ports.

Now this is a good start into 2021 for me !!!

1 reply

GS1
GS1AuthorBest answer
Senior III
December 30, 2020

OK, I got it:

The correct RAM initialisation is done as follows:

if (nCan == CAN0)

{

      phCan->Instance = FDCAN1;

      uCANOffset = 0;

}

else

{

      phCan->Instance = FDCAN2;

      uCANOffset = 1024;

}

   phCan->Init.MessageRAMOffset = uCANOffset;

   ...

   phCan->msgRam.StandardFilterSA = 0;

   phCan->msgRam.ExtendedFilterSA = 0;

   // Start-Adressen für Message-RAM:

   phCan->msgRam.RxFIFO0SA = 0;

   phCan->msgRam.RxFIFO1SA = 0;

   phCan->msgRam.RxBufferSA = 0;

   phCan->msgRam.TxEventFIFOSA = 0;

   phCan->msgRam.TxBufferSA = 0;

   phCan->msgRam.TxFIFOQSA = 0;

   phCan->msgRam.TTMemorySA = 0;

   phCan->msgRam.EndAddress = 0;

   phCan->ErrorCode = 0;

This ensures that both CANs can be used without conflict in the RAM for receiving messages.

Hope this helps others for initialising 2 x FDCAN-Bus ports.

Now this is a good start into 2021 for me !!!