2013-02-12 04:25 AM
I try to enter malloc for some area at my program
I use IAR 6.4 with STM32F205ZC.first i annunce the buffer pointeruint16_t * ADC3ConvertedValue;
and then I call the functionADC3ConvertedValue = (uint16_t*) malloc (500 );
free(ADC3ConvertedValue);I have a lot of free RAM space (use only 18K of 96K) but even I put this function at the beginning of the program it return NULL if I ask more then 500 bytes(even 511). Is there more setting i need to do or it is the compiler or the MCU limitation?RegardsBar.2013-02-12 05:11 AM
A heap setting?
Using dynamic memory is usually avoided on embedded systems as the heap is prone to fragment, and allocations fail.2013-02-12 11:21 PM
2013-02-12 11:57 PM
So if I increase my heap space can it help?
It will address the near term issue. Where this is done in IAR I'm not sure, but you should be able to define a reasonably large chunk if you choose too. Long term you have to understand your memory usage, if you can use the stack for some of the transient requirements, or if you need to allocate from a fixed pool. What needs static allocation, and can that overlap with other mutually exclusive uses.