|
|||||||||||
Technical Support Support Resources
Product Information |
C51: Bit Field Unions Don't Work as ExpectedInformation in this article applies to:
SYMPTOMSI have created a union of a bit field structure and an unsigned integer. When I set bit 0 of the unsigned int, the corresponding bit field is not set.
CAUSEThe 8051 is a big endian architecture (opposite of all other Intel chips). This means that the MSB comes first and the LSB comes last. Your assignment sets bit 0 in the second byte of the union. The bit field bit_0 is located at bit 0 in the first byte of that union. RESOLUTIONIn your example, to set the bit field bit_0, you would need to change your assignment from:
to:
SEE ALSO
Last Reviewed: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.