This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

union, bit field and bdata

I want to fix (in C langage if possible)
in bdata memory a word (u16). At the same address I want to use 2 bytes (u08) and always in the same area (0x20 and 0x21 addresses for example) to declare bits with sbit structure.
---------------------------------------
u16 bdata myByte;
sbit myBit15 = myWord ^ 15;
sbit myBit3 = myWord ^ 3;
// it does affect the right bit. Why ?
---------------------------------------
union u{
u08 bdata msb;
u08 bdata lsb;
} myWord;
union {
u16 bdata word _at_ 0x20;
union u myWord;
} MYword;
sbit myBit15 = myWord.msb ^ 7;
sbit myBit3 = myWord.lsb ^ 3;

... // use
{
MYword.word;
myWord.msb;
myWord.lsb;
myBit15; // not known by compiler ?
myBit3; // not known by compiler ?
}