I've run into an issue working with arrays of pointers where writing values to the pointer array elements seems to work fine (the correct addresses are assigned in memory and are 32-bit aligned since I am using the large data model for a MSP430F2618) but the dereferenced array values appear to be read back by the IDE and later code as 24-bit aligned values. This doesn't really make sense to me but here is some toy code to illustrate the issue:
#define STRUCT_LIST_SIZE 4
typedef struct SOME_STRUCT
{
char cParam1;
char cParam2;
int iParam3;
}xSomeStruct;
typedef xSomeStruct * pxSomeHandle;
static pxSomeHandle pxStructHandleList[ STRUCT_LIST_SIZE ];
int main( void )
{
xSomeStruct xStructA, xStructB, xStructC, xStructD;
int i;
for( i = 0; i < STRUCT_LIST_SIZE; i++ )
{
pxStructHandleList[i] = 0x0000;
}
pxStructHandleList[0] = &xStructA;
pxStructHandleList[1] = &xStructB;
pxStructHandleList[2] = &xStructC;
pxStructHandleList[3] = &xStructD;
return 0;
}
Here is what the memory view shows me after all of the array elements have been assigned:
0x001100 .bss, _bss, pxStructHandleList
0x001100 30EA 0000 30EE 0000 30F2 0000 30F6 0000
Which matches my expectations but when I look at pxStructHandleList in the Watch window I see this:
pxStructHandleList 0x001100
[0] 0x0030EA
[1] 0x30EE00
[2] 0xF20000
[3] 0x000030
When I try to access the structures using the pointer array (pxStructHandleList[i]->cParam1) it looks like it uses the addresses as represented in the watch window (half of which are invalid) and things just break down from there. Does anyone have some insight into what is going on? Thanks in advance!
BTW I am using CCS V4.0.0.16000 microcontroller edition and working with a MSP430F2618.