The SDK for the LPCXpresso54S018 comes with an example called mcan_interrupt_transfer. It is an mcan example under the set of driver_examples. The example is written in C. I am using this example as a basis to create a C++ application that does something similar.
In the example, there is the following line of code:
SDK_ALIGN(uint8_t msgRam[MSG_RAM_SIZE], 1U << CAN_MRBA_BA_SHIFT) = {1U};
This is aligning the CAN message RAM to 0x10000.
When I specify the same line of code in my C++ code, the variable appears to locate to address zero. However, in the file fsl_mcan.h there is the following code:
static inline void MCAN_SetMsgRAMBase(CAN_Type *base, uint32_t value)
{
assert(((value >= 0x20000000U) && (value <= 0x20027FFFU)) || ((value >= 0x04000000U) && (value <= 0x04007FFFU)));
base->MRBA = CAN_MRBA_BA(value >> 16U);
}
This code causes an error to be asserted because of the address of the CAN message buffer.
I have tried using the following statement instead to align the message buffer, but it still does not put the CAN message buffer into the desired location.
__attribute__((aligned(1U << CAN_MRBA_BA_SHIFT), section(".bss_RAM2"))) uint8_t msgRam[MSG_RAM_SIZE] = {1U};
.bss_RAM2 appears to be a valid memory section from my load map and it resides at 0x20000000.
How to I properly align the CAN message buffer so that the check in MCAN_SetMsgRAMBase does not fail?