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.

LM3S8971: Memory Overlap when using unsigned char variable and char array

Part Number: LM3S8971

Tool/software:

Hi, I'm currently working on an older board to maintain a legacy application with CCSv5, TI compiler v5.1.1, opt lvl 0, bare metal.

I'm facing an issue where 2 of my unsigned char variables are allocated addresses that are on top of a character array size 5. Example

char a[5] = {0, 0, 0, 0, 0};

unsigned char b = 0;

unsigned char c = 0;


map file shows that:

200055a1 for b

200055a2 for c

2000559c for starting address of a

Changing b and c to unsigned long alleviates this problem. Could I ask for some lights on this particular problem? Thank you so much!

  • Hi,

      First of all, TI compiler v5.1.1 is an extremely old version. 

      

    I'm facing an issue where 2 of my unsigned char variables are allocated addresses that are on top of a character array size 5. Example

    char a[5] = {0, 0, 0, 0, 0};

    unsigned char b = 0;

    unsigned char c = 0;


    map file shows that:

    200055a1 for b

    200055a2 for c

    2000559c for starting address of a

    I don't understand what you meant that there is a problem. I don't see a problem. 

    char a[5] takes up 5 bytes and it occupies addresses 2000559c, 2000559d, 2000559e, 2000559f and 200055a0. char b is one byte at 200055a1 and char c is also one byte at 200055a2. 

    If you can elaborate your problem then perhaps I can forward your question to our compiler expert.