Accessing bit fields using a union problem.
Hello - I changed my code from my last post:
so that the struct of bit fields is unionized with a UINT32 word:
When I print out hwReg.word I get the entire correct 32 bits - BUT when I print out one of the bits hwReg.bits.maskn, I get 0x00000000 - I think it still may be accessing the bits as bytes even though the struct is unionized with UINT32. what is going on?
/// Reserved - read as 0
unsigned reserved : 30;
/** This bit contains the interrupt status. Reading this register
* clears this bit.
unsigned stats : 1;
/** This field masks the interrupt.
* 0 - Masked
* 1 - Enabled
unsigned maskn : 1;
unsigned long word;
} volatile RegStruct;