cancel
Showing results for 
Search instead for 
Did you mean: 

STVD + Cosmic. Heap Size?

dexter_khm
Associate II
Posted on March 19, 2015 at 14:53

Hello i am using STVD + Cosmic with stm8s105k4t6. And i have a problem. I need to allocate an array with 612 cells but:

current_packet.data = (uint8_t*)malloc(current_packet.size+2);

if (current_packet.data == 0)

bytecount = 0;

But I cant because current_packet.data stays in zero. In smaller sizes of array this code works well. How can I set heap size bigger, to fit this Jumbo array :-)? Where those setting are in STVD + Cosmic?

#heap #stvd #cosmic
5 REPLIES 5
luca239955_stm1_st
Senior II
Posted on March 20, 2015 at 08:35

Hello,

please post your .lkf and .map files so that we can have an idea of how the memory is managed in your application.

Regards.

dexter_khm
Associate II
Posted on March 20, 2015 at 16:24

map https://dl.dropboxusercontent.com/u/92887381/discover.map

lkf  https://dl.dropboxusercontent.com/u/92887381/discover.lkf

luca239955_stm1_st
Senior II
Posted on March 20, 2015 at 18:37

from the files you posted it looks like you have a total ''data'' space of 0x500 bytes - (100+110) = 1070 bytes available for the heap.

Therefore if you try to allocate an array of 612 chars it should work (at least the first time), but an array of 612 ints is already too big.

Hope it helps.

dexter_khm
Associate II
Posted on March 22, 2015 at 17:25

So can I make heap region bigger? My MCU has 2K of RAM.

luca239955_stm1_st
Senior II
Posted on March 23, 2015 at 13:26

yes, you can, as long as all your 'data' fits into the 2k (variables + heap + stack).

Look for 'heap' in the compiler user manual to see what you have to modify in the linker file: I'm not sure you can do that via STVD's menu, you will have probably to use the Custom Linker file option and modify by hand.

Regards.