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.

Different array declaration in the same Shared Memory

Other Parts Discussed in Thread: F28M36P63C2

Hi,

Is there a way to declare different kind of array in the same Shared Memory?

For example:

int firstarray[20];
float secondarray[20];

#pragma DATA_SECTION(firstarray,"SHARERAMS2"); 
#pragma DATA_SECTION(secondarray,"SHARERAMS2"); 

But this is not working.

Thank you,
Marc 

  • Marc Zetek said:

    Is there a way to declare different kind of array in the same Shared Memory?

    For example:

    int firstarray[20];
    float secondarray[20];

    #pragma DATA_SECTION(firstarray,"SHARERAMS2"); 
    #pragma DATA_SECTION(secondarray,"SHARERAMS2"); 

    But this is not working.

    Marc - please elaborate on how it isn't working? (i.e. what are the symptoms).  

    How big is the shared memory you are allocating to? 

    What does the linker file look like? 

    What did you get vs what you expected - i.e. did the linker use a different location or did it issue an error?

    Thank you

    Lori

  • Hi Lori,

    In fact, the secondarray takes the space memory of the first one. It doesn't place it after the firstarray.

    The shared memory is 8KB.

    I tried to write something like this :

    #pragma DATA_SECTION((firstarray | secondarray),"SHARERAMS2"); 

    But it doesn't like it. :)

    I don't get any error and the linker is right linked. So right now, I just created different shared memory for "int" and for "float". But if you have any idea, i'll take it :-).

    Thank you Lori,
    Marc 

  • Marc Zetek said:
    In fact, the secondarray takes the space memory of the first one. It doesn't place it after the firstarray.

    hmmm it shouldn't be the case unless you tell the linker to do so using a UNION directive. 

    I tried to reproduce this -

    I am not sure which device you are using so I just grabbed the CPU timer example for 2806x.

    I added two global arrays and 2 pragma statements:

    #pragma DATA_SECTION(firstarray,"SHARERAMS2");
    #pragma DATA_SECTION(secondarray,"SHARERAMS2");

    int firstarray[20];
    float secondarray[20];

    void main(void)
    {

    .....

    Then in my linker command file I allocated the section:

       SHARERAMS2       : > RAML5,      PAGE = 1

    In the generated map file I see:

    ....

    0000a11e   __dtors_ptr
    0000c000   _firstarray
    0000c014   _secondarray
    003d7e80   _PartIdRegs

    .....

    -Lori

  • Lori,

    I'm using the F28M36P63C2 device. 

    Ok, I can see on the C28 side that there are different location for the first and the second array. I don't know what happened the first time I tried it...

    But on the M3 side I can't see any of my arrays in the .map file generated. It looks like another question, I'm sorry but I can't test what you replied to me on the m3 side.
    It is like the Shared Rams are not initialized  because it doesn't appear in the section part of the .map file while it is in the .cmd linked file.

    Is there any intialization to do on the m3 side for the shared memory? I don't see any in the example projects.

    Thank you,
    Marc 

  • Marc Zetek said:
    But on the M3 side I can't see any of my arrays in the .map file generated.

    Looks like the ARM compiler is tossing them out because they are never used.  You can either make them volatile or use them in main() and you should see them in the map file:

    #pragma DATA_SECTION(firstarray,"SHARERAMS2");
    #pragma DATA_SECTION(secondarray,"SHARERAMS2");

    int     firstarray[20];
    float     secondarray[20];

    //*****************************************************************************
    //
    // Blink LED3
    //*****************************************************************************
    int
    main(void)
    {

        volatile unsigned long ulLoop;
        firstarray[0] = 5;                                                // use the array so it isn't compiled out
        secondarray[0] = 10.3;               // use the array so it isn't compiled out


    Linker .cmd file:

    SECTIONS
    {
        .intvecs:   > INTVECS
        .resetisr:  > RESETISR
        .text   :   >> C0 | C1 | C2 | C3
        .const  :   >> C0 | C1 | C2 | C3
        .cinit  :   >  C0 | C1 | C2 | C3
        .pinit  :   >> C0 | C1 | C2 | C3

        .vtable :   >> C0 | C1 | C2 | C3
        .data   :   >> C2 | C3  
        .bss    :   >> C2 | C3  
        .sysmem :   >> C0 | C1 | C2 | C3
        .stack  :   >  C0 | C1 | C2 | C3

        SHARERAMS2       : > C15



    Map file:

    2002e000   firstarray
    2002e050   secondarray

    Regards,

    -Lori