Content originally posted in LPCWare by CodeRedSupport on Thu May 31 03:45:01 MST 2012
Hmm. OK. I should have read the previous couple of posts properly and also built atomicdog's example before posting my previous answer.:rolleyes:
Anyway, in order to get all the byte element structs nicely packed together you need to...
1) Compile -Os.
2) Ensure that all the structs are in the same section. To do this, either give them all an initial value or don't give any of them an initial value at time of declaration.
Note that leaving the initial value "blank" versus setting the initial value to zero is not the same with regards to the compiler placing them into the same block of memory....
volatile MY_STRUCT_T xyz = {0,0,0,0,0} ;
volatile MY_STRUCT_T foo;
Thus you either want ...
volatile MY_STRUCT_T xyz = {0,0,0,0,0} ;
volatile MY_STRUCT_T foo = {0,0,0,0,0};
or
volatile MY_STRUCT_T xyz;
volatile MY_STRUCT_T foo;
Regards,
CodeRedSupport