Part Number: MSP432P4111
Tool/software: TI C/C++ Compiler
Hi,
Tools:
MSP432P4111
CCS 10.1.0.00010
TI ARM V20.2.1.LTS
Overview:
I have a type of structure designed to be constant (in program memory) such that I can iterate through groups of the structures and determine the value of a local variable based on its address for purposes of streaming that variable and groups of variables over a packet network.
I have a single item entry:
/** A single item entry used to define a variable */ typedef struct { /** The type of variable the user wishes to implement */ TE_RVAR__VARIABLE_TYPE eVariableType; /** User to set this to an enumerated user type unique to their project */ Luint32 u32UserType; /** Pointer to the variables address */ void *vpData; }TS_RVAR__ITEM_ENTRY;
And then I have groups of items:
/** The groups of variables that can be used in an array */ typedef struct { /** A pointer to an array of variable items for the current group. */ const TS_RVAR__ITEM_ENTRY *tsEntryArray; }TS_RVAR__PARAM_GROUP;
Implementation:
I create a constant structure of variable items such as:
// LTE const TS_RVAR__ITEM_ENTRY tsRVAR_GROUP_0[] = { { .eVariableType = RVAR_VARIABLE_TYPE__U8, .u32UserType = AX_RVAR_USER__LTE__STATEMACHINE, .vpData = (void *)&sSARA.eMain }, { .eVariableType = RVAR_VARIABLE_TYPE__STRING_32, .u32UserType = AX_RVAR_USER__LTE__APN, .vpData = (void *)&sSARA.u8APN32[0] }, /** Must have an end marker for each group */ { .eVariableType = RVAR_VARIABLE_TYPE__END_MARKER, } }; // WiFi const TS_RVAR__ITEM_ENTRY tsRVAR_GROUP_1[] = { { .eVariableType = RVAR_VARIABLE_TYPE__U32, .u32UserType = AX_RVAR_USER__WIFI__MAIN_STATEMACHINE, .vpData = (void *)&sCC3X20.sSM.eState }, { .eVariableType = RVAR_VARIABLE_TYPE__U32, .u32UserType = AX_RVAR_USER__WIFI__IPV4, .vpData = (void *)&sCC3X20.sSM.sConnected.u8IPV4[0] }, /** Must have an end marker for each group */ { .eVariableType = RVAR_VARIABLE_TYPE__END_MARKER, } };
And then create an overall group which my application iterates over:
const TS_RVAR__PARAM_GROUP tsRVAR_ITEMS[C_LOCALDEF__LCCM1133__NUM_GROUPS] = { /* Group 0 - LTE */ &tsRVAR_GROUP_0[0], /* Group 1 - WIFI */ &tsRVAR_GROUP_1[0], };
Results:
Randomly the compiler does not seem to insert the correct address of the variable. By randomly I mean that some of the addresses of the variables are correct, and some are wrong. To me it seems like the compiler does not know that a variable like eState within a structure is only one byte, and I think it assumes its 4 bytes. Or that maybe it needs some alignment.
For example, in Group 1, Item 0 I am pointing to the address of a state-machine variable which is located in RAM at 0x200355C3
However the compiler inserts the wrong address ox 0x2003559B into the constant pointer in program memory. The addresses are not even close 0xC3 v's 0x9B.
Wondering if anyone can see anything obviously wrong with my code, or is this an anomaly in the compiler?
I have naturally full erased the device, cleaned the project and created a new workspace, nothing changes the results.
Thanks
Stomp!