Skip to main content
dexter_khm
Associate II
Mar 19, 2015 1:53 PM UTC
Question

STVD + Cosmic. Heap Size?

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
    This topic has been closed for replies.

    5 replies

    luca239955_stm1_st
    Associate
    Mar 20, 2015 7:35 AM UTC
    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
    Mar 20, 2015 3:24 PM UTC
    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
    Associate
    Mar 20, 2015 5:37 PM UTC
    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
    Mar 22, 2015 4:25 PM UTC
    Posted on March 22, 2015 at 17:25

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

    luca239955_stm1_st
    Associate
    Mar 23, 2015 12:26 PM UTC
    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.