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.

CCS/MSP430G2553: Wrong data alignment (MSP430G2553, in CCS v7)

Part Number: MSP430G2553


Tool/software: Code Composer Studio

Hi,

I encountered wrong data alignment when using structure in CCS v7.0.

Please advise.

Thank you in advance.

 

IDE : CCS ver.7.0.0.00042

MCU : MSP430G2553

Launchpad : MSP-EXP430G2 (rev 1.5)

 

[define below structure] :

typedef struct {

  unsigned char x;

  unsigned char a[16];

} XA;

[declare variables] :

XA y;

unsigned short *p;

 

[assign the following instruction] :

// I want to access the array y.a[] by the pointer *p:

p = (unsigned short *)&y.a[0];

*p = 0x0708;

[BUT, got wrong alignment result] :   y.x = 0x08   &   y.a[0] = 0x07   !!!

 

[another instruction] :

p = (unsigned short*)&y.a[1];

*p = 0x0708;

[this time result is correct] :   y.a[1] = 0x08   &   y.a[2] = 0x07.

 

Seems that, it's even-address-aligned !!!

 

 

Thanks