lpcware

LPC1853 Changing Heap & Stack Sizes

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by wcarlsen on Thu Mar 26 08:01:27 MST 2015
Looking in the startup.s file that Keil provides with their uVision 5 IDE for the LPC1853 it initializes the Heap to 0x400 and the stack to 0x200. So can I increase the heap size to like 100k or will that have some negative side effect?

My understanding of how the memory allocation with SRAM works (of which there is 136kB on the 1853 per the datasheet) is that the static and global variables start filling up the SRAM from the bottom and then the Stack starts filling up the SRAM from the top and moving downward. It is also my understanding that the Heap then sits on top of the static section and works its way up.

So if my understanding is wrong, please do correct me and perhaps point me to an article, book, etc. that I can read. I would appreciate the resources as I am pretty new to embedded programming and trying to get a better understanding of memory etc.

But if my understanding if correct, then wouldn't that mean that there is an insane amount of wasted SRAM at the moment? Becasue the 0x400 and 0x200 only account for like 1.5k of ram but the chip has 138k I believe.

The specific reason I am posting this is because I found a PDF about C design patterns I was reading the other night and there is one called first class ADT but it relies on malloc() which was returning null for me because I was running out of heap after several calls to malloc() because the structs I was using malloc() on were like 300 bytes each.

Thanks in advance for any help!
Wesley

Outcomes