cpp lpc1549 default stack pointer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

cpp lpc1549 default stack pointer

793 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by efiLabs on Sun Jun 22 23:25:43 MST 2014
friends :

a question arises for the lpc1549 : lpcxpresso 7.2.0 cpp (C++ lpcopen proj)

the default stack pointer seems to be assigned at the end of xxx_Debug.ld linker script

       PROVIDE(_pvHeapStart = .);
    PROVIDE(_vStackTop = __top_Ram0_16 - 0);
}

the location of __top_Ram0_16 is at 0x02004000 which is at the end +1 of the 1st 16 k sram "Ram0"

the lpc1549 has 2 x 16 k + 4k sram

one would assume that it should by default be placed at the end of sram +1 which is 0x02009000

i did a quick and dirty hack of hard coding this void (*)() function pointer in cr_startup_lpc15xx.cpp and my pgm works now since i use at least 32 k sram ... it took a while to figure it out since i 1st assumed my pgm is somehow at fault

this can't be the intended fix for it i assume.

what's the appropriate solution for it ... i can't just start hacking happily away, right from the start

thanks, cheers efiLabs


Labels (1)
0 Kudos
4 Replies

708 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by efiLabs on Mon Jun 23 09:59:37 MST 2014

thank you very very much for pointing out all of the options ... the one with changing the startup code seems the most logical and less intrusive

thanks, cheers efiLabs
0 Kudos

709 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Jun 23 02:38:00 MST 2014

Quote:
Properties -> C/C++ Build -> MCU Settings -> Memory configuration editor and merging all 3 ram regions into one ??? correct ???

do i still need to call the combined sram region Ram0_16 or can i call it Ram0_all as an example ???


Yes, you can merge them all. You can name it whatever you want.

Quote:


if i make these changes tomorrow and check it ... it's past midnight here in Ca ... will these changes be permanent for all future lpc1549 project creations ??? or only for this one ???


Only this one. You can use the Export/Import buttons on the memory configuration editor to move the configuration between different projects

Quote:

my thought was, since the 3 sram regions are contiguous in nature, no gaps, the lpc1549 project creation out of the box would adjust automatically to the end of the sram

why would someone buy a 36 k part and then want the stack pointer in the middle of the 36 k and fiddle with 3 regions ???


It was done this way because the 2 other banks can be powered off (to save power).

Quote:

since they are contiguous, the plain vanilla thought is to treat it as memory and if anyone wants something special they can adjust the cpu to their individual segmented needs.

sorry ... no criticism, just some thoughts ... i buy a cpu out of the box cause it has 36 k (which isn't a lot to begin with) then most users have one memory. nice to allow for segmentation if needed and use it ... like i thought ...

again ... just some thoughts ... i'm sure your answer before will help others as well to shine light onto where the default stack pointer is


Another way to move the stack is to change the Startup code. The linker script defined the top of each RAM bank and you can use these symbols to change the stack initialiser.
Add this to the startup code:
extern void __top_Ram2_4(void); // definition from the linker script

And edit the stack initialiser to:
&__top_Ram2_4,                       // The initial stack pointer

And you do not need to change your linker script.
0 Kudos

709 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by efiLabs on Mon Jun 23 01:50:39 MST 2014
thanks for the reply :

since i do not want a custom linker script, the suggested way seems to be the following

Properties -> C/C++ Build -> MCU Settings -> Memory configuration editor and merging all 3 ram regions into one ??? correct ???

do i still need to call the combined sram region Ram0_16 or can i call it Ram0_all as an example ???

if i make these changes tomorrow and check it ... it's past midnight here in Ca ... will these changes be permanent for all future lpc1549 project creations ??? or only for this one ???

my thought was, since the 3 sram regions are contiguous in nature, no gaps, the lpc1549 project creation out of the box would adjust automatically to the end of the sram

why would someone buy a 36 k part and then want the stack pointer in the middle of the 36 k and fiddle with 3 regions ???

since they are contiguous, the plain vanilla thought is to treat it as memory and if anyone wants something special they can adjust the cpu to their individual segmented needs.

sorry ... no criticism, just some thoughts ... i buy a cpu out of the box cause it has 36 k (which isn't a lot to begin with) then most users have one memory. nice to allow for segmentation if needed and use it ... like i thought ...

again ... just some thoughts ... i'm sure your answer before will help others as well to shine light onto where the default stack pointer is

thanks again, cheers efiLabs

0 Kudos

708 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Jun 23 00:26:31 MST 2014
The LPC15xx parts have three blocks of RAM, with the ability to enable/disable the second and third banks separately. For more details see the LPC15xx User Manual, Chapter 1: LPC15xx Memory mapping.

http://www.lpcware.com/content/nxpfile/lpc15xx-user-manual

As the RAM banks are contiguous, you can merge them if required using the memory configuration editor (as described in the LPCXpresso User Guide). The stack will then be automatically placed at the end of the 1st RAM bank (as defined after your editing of the memory map).

Or alternatively you could move the stack (and heap) to the second (or third!) RAM block using a linker script template - as described at:

http://www.lpcware.com/content/faq/lpcxpresso/linker-script-templates

Regards,
LPCXpresso Support
0 Kudos