gjm27n
Joined: 15 Jun 2016 Posts: 23
|
Any idea what is wrong with this union? |
Posted: Sun Jul 10, 2016 1:28 pm |
|
|
Here are relevant snippets of code
Code: |
union LONG_UNION
{
signed int32 sl;
unsigned int32 ul;
signed int16 si[2];
unsigned int16 ui[2];
signed int8 sc[4];
unsigned int8 uc[4];
};
union LONG_UNION ulActiveAddr;
ulActiveAddr.uc[3] = 0x00;
ulActiveAddr.uc[2] = 0x00;
ulActiveAddr.uc[1] = 0x01;
ulActiveAddr.uc[0] = 0x00;
printf("Part Addr = %8X, %2X, %2X, %2X, %2X\n",
ulActiveAddr.ul,
ulActiveAddr.uc[3],
ulActiveAddr.uc[2],
ulActiveAddr.uc[1],
ulActiveAddr.uc[0]);
|
Prints the following
Part Addr = 00000000, 00, 00, 01, 00
I think it should print
Part Addr = 00000100, 00, 00, 01, 00
I'm using this to access an address on an external eeprom. |
|