This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F2274 memory allocation

Other Parts Discussed in Thread: MSP430F2274

Hi, similar to the malloc() function, are there any functions that i can use to create a dynamic memory in msp430f2274 ?

I need to code some stuff using link lists as they seem simpler.

  • Muhammad,

     

    Although it is possible to use dynamic memory allocation on the MSP430, I would recommend for you to find alternatives. Memory allocation on any microcontroller with limited memory will be problematic.

     

    Gustavo

  • Gustavo L said:
    Memory allocation on any microcontroller with limited memory will be problematic.

    While I agree for the typical use of malloc (allocating more and more memory based on events or incoming data), there is a use for this under mspgcc or IAR (not CC, see below):

    When you need to allocate a large buffer space, e.g. for a file system or collecting data etc., which does not need to be initialized, it might be a good idea to allocate it dynamically. Then it is not put into the uninitialized variables segment (or worse the initialized variables segment) and does not take any time at startup for clearing out its content, or worse copying its empty content from flash to ram. And startup time might be critical.

    CC does not clear uninitalized variables (different from the 'usual' C implementation), so this does not apply here

    mspgcc, has an attribute to move variable sinto an 'uninitialized' area, so there this is an alternative for using malloc. . It works, however, with any compiler, so it is portable.

  • Im using code composer v4. Are you to say that we are able to use malloc? Do you know where i can find the appropriate malloc.h file

  • Muhammad Razali said:
    Do you know where i can find the appropriate malloc.h file

    malloc() is part of the standard C library package, the definition can be found in stdlib.h

    It depends, however, on the compiler manufacturer whether this funciton is implemented/provided.

**Attention** This is a public forum