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.

Array of struct not being allocated correctly using DATA_SECTION

In my linker cmd file I have a MEMORY PAGE 1 definition of the below:

SHARED_MEM : origin = 0x100080, length = 0x00FF80

I then defined a section for that memory of the below:

Shared_MemFile      : > SHARED_MEM,  PAGE = 1

I have a struct defined as below:

 

struct DATA_TBL

{

  Uint16 TBL_TAG_WORD;

  Uint16 TIME_TAG[2];

  Uint16 DATA_BUF[32];

};

I now want to create a bunch of arrays of that struct and have them located in the Shared_MemFile section defined above.  I have the following in a .c file (and a bunch of others similarly defined):

#ifdef __cplusplus
#pragma DATA_SECTION("Shared_MemFile")
#else
#pragma DATA_SECTION(DataTbl1, "Shared_MemFile");
#endif
volatile struct DATA_TBL  DataTbl1[32];

 

Everything compiles and links fine, but when I look at the map file I have the following for that entry and the next one in memory:

001018c0   _DataTbl1

00101d00   _DataTbl5

The delta size is only 0x40 words, which is one page (I believe that 1 page is 64 words).  The size of the struct is 35 words, and I created an array of 32 of those.  Why does it only seem to be creating 1 element of the array?  As a test, I used the same code section but did: volatile Uint16 test[256];   and put it in the same section of memory. When I look at the map file, that correctly shows up with having a gap of 0x100 between it and the next item in memory.  What is unique about the struct and how would I achieve what I want?


 

  • Hi Stephen,

    Stephen V said:

    Everything compiles and links fine, but when I look at the map file I have the following for that entry and the next one in memory:

    001018c0   _DataTbl1

    00101d00   _DataTbl5

    The delta size is only 0x40 words, which is one page (I believe that 1 page is 64 words). 

    Is there something else between DataTbl1 and 5?  If not I think you may have misread the address - the offset is 0x440 words but that still seems low by 0x20 words.

    Maybe I need to sleep on it :)

    -Lori

  • Hi Lori,

    Thank you for your response. I turned on the "No DP load optimization" flag and saw the map file looked correct, so I moved on.  Now that you have responded and pointed out the error, I went back and turned off the No DP load optimization flag and looked at the map file again and it looks correct.  I don't know how I overlooked that before, because I swear I stared at it for a while (maybe too long!).   I guess everything is fine now, thank you again for your response.