LPC5516
MCUXpresso version 11.7.1
SDK version 2.13.0
When I enabled "Allocate messages RAM" for MCAN in the peripherals tool my SRAM usage goes from...
Memory region Used Size Region Size %age Used
PROGRAM_FLASH: 17660 B 244 KB 7.07%
SRAM: 8496 B 64 KB 12.96%
USB_RAM: 0 GB 16 KB 0.00%
SRAMX: 0 GB 16 KB 0.00%
to
Memory region Used Size Region Size %age Used
PROGRAM_FLASH: 20268 B 244 KB 8.11%
SRAM: 73964 B 64 KB 112.86%
USB_RAM: 0 GB 16 KB 0.00%
SRAMX: 0 GB 16 KB 0.00%
I have almost everything in the MCAN initialization set to zero, so it's only allocating 10 bytes. I assume it's something to do with the alignment. What am I doing wrong?
Solved! Go to Solution.
Hi the MCAN in the LPC55xx series needs to be alligned to 0x10000!
for a solution.
What I did in my lates project is:
- define a memory section in the linker settings:
then define the MCAN Buffer area like this (for example in main.c):
uint32_t __attribute__((section (".CanBuffer")))CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE] __attribute__ ((aligned (0x10000)));
Martin
Hi the MCAN in the LPC55xx series needs to be alligned to 0x10000!
for a solution.
What I did in my lates project is:
- define a memory section in the linker settings:
then define the MCAN Buffer area like this (for example in main.c):
uint32_t __attribute__((section (".CanBuffer")))CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE] __attribute__ ((aligned (0x10000)));
Martin
Thanks, that helped quite a bit.
I understand now that the reason for the error is that the LPC5516 chip only has 0x10000 (64k) of SRAM. So the only place the CAN buffer can go is right at the start. When the peripheral tool tries to align the buffer, the linker tries to place it at address 0x10000 after the start SRAM, i.e., at the very end of (and outside of) SRAM.
I'm not sure if there's a more elegant way of doing this, but I seem to have solved the problem by splitting the SRAM and adding a new 1k section in the Memory details.
And then adding it in the extra linker script inputs as you suggested:
And now the linker is happy:
For anyone else that runs into this make sure you also disable "Allocate messages RAM" in the peripherals tool. I expect it won't work properly on any chip with exactly 64k of SRAM
In absence of any further information, I would say check the map file.
If necessary, compare the map files for both cases.