AnsweredAssumed Answered

union value issue

Question asked by 赵子成 on Jul 7, 2018
Latest reply on Jul 11, 2018 by 赵子成

Hi, everyone,


Now I use S32K146, I define a union type variable as follow:

typedef union unCanFrameData
UINT8 u8Data[CAN_FRAME_DATA_LEN]; ///< 8 uint8 data
UINT16 u16Data[4]; ///< 4 uint16 data
UINT32 u32Data[2]; ///< 2 uint32 data


But when I set the u16Data[2]:

unData.u16Data[2] = 2000

I get the follow result:

The problem is that the u16Data[2] is 2000, but the u8Data[4] and u8Data[5] is 0, the data is not Coincident.

Can anyone help me? Thanks.