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.

Allocating C program structure members in different RAMS, namely SARAM and DARAM for CCs_ver4.0

BACKGROUND:

I am working with the code composer studio CCs_ver4.0 simulator on window 7 OS for the C55x revision 3 core.

I have some C code which declares structures. Also memory is allocated to these structure variables using malloc.

QUESTION:

Now say there is a structure declared in C code:

 

 

 

 

typedef

 

 

struct st1{int dummy; int weights[10]; int lms_buffer[20];

}lms_internal;

Within a main.c file I am allocating memory as: p_int = (int *)malloc(sizeof(lms_internal));

Now if i want to put structure member weights in SARAM whereas structure member lms_buffer in DARAM then

how can I specify this in the linker command file ? In what way can I have two structure member  arrays in totally different sections of memory ? 

Pragma cannot be used according to me since this is for variables defined at the file level. 

Thanks,

AV.

  • The only way I can think of is to use BIOS.  You can create heaps in different memories and then you use the MEM_alloc to reserve the memory.  Details can be found in the BIOS API Reference Guide (http://www-s.ti.com/sc/techlit/spru404).

    Perhaps someone else has a better suggestion.

    Regards.

  • Probably what Tommy suggested is the best alternative using dynamic memory allocation. Now, if you want to use static memory allocation, you could use #pragma DATA_SECTION directive:

     

    #pragma DATA_SECTION(weights, “.weightsbuffer”)

    int weights[10]; 

     

    #pragma DATA_SECTION(lms_buffer, “.lmsbuffer”)

    int lms_buffer[20]; 

    struct st1{

       int dummy; 

       int *weights_ptr = &weights;

       int *lms_buffer_ptr = &lms_buffer;

    }lms_internal;

    Then in your command file SECTIONS directive allocate these buffers to the memory that you want:
    SECTIONS {

      . weightsbuffer > SARAM

      . lmsbuffer > DARAM

    }

     

    Note that if you create the structure with the arrays in it, then the whole structure and arrays would be placed in the same memory at continuous locations.

    best regards,

      Pedro

     

  • Pedro and Tommy,

    Thanks for your replies.

    I am not going to be using DSP/BIOS. But as a work around to this issue I am removing the two arrays outside the structure, using static memory

    allocation to allocate memory for these two arrays and then use the pragmas as Pedro has suggested.

    Regds,

    AV.