2020-12-29 10:49 AM
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.
Solved! Go to Solution.
2020-12-30 01:25 AM
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 !!!
2020-12-30 01:25 AM
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 !!!