Enabling MCAN in Peripherals tool breaks SRAM calculation

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Enabling MCAN in Peripherals tool breaks SRAM calculation

跳至解决方案
990 次查看
wilkinsw
Contributor III

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?

0 项奖励
回复
1 解答
937 次查看
MartinHo
Contributor IV

Hi the MCAN in the LPC55xx series needs to be alligned to 0x10000! 

see https://community.nxp.com/t5/LPC-Microcontrollers/CAN-base-address-align-restriction-in-LPC55/m-p/13...

for a solution.

What I did in my lates project is:

- define a memory section in the linker settings:

MartinHo_0-1688813009203.png

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

在原帖中查看解决方案

3 回复数
938 次查看
MartinHo
Contributor IV

Hi the MCAN in the LPC55xx series needs to be alligned to 0x10000! 

see https://community.nxp.com/t5/LPC-Microcontrollers/CAN-base-address-align-restriction-in-LPC55/m-p/13...

for a solution.

What I did in my lates project is:

- define a memory section in the linker settings:

MartinHo_0-1688813009203.png

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

879 次查看
wilkinsw
Contributor III

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.

wilkinsw_0-1689007546429.png

And then adding it in the extra linker script inputs as you suggested:

wilkinsw_1-1689007587190.png

And now the linker is happy:

wilkinsw_2-1689007612090.png

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

wilkinsw_3-1689007700717.png

 

0 项奖励
回复
952 次查看
frank_m
Senior Contributor III

In absence of any further information, I would say check the map file.
If necessary, compare the map files for both cases.

0 项奖励
回复