Discussion Forum

union, bit field and bdata

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
gouezel yann
Posted
20-Jul-2001 16:02 GMT
Toolset
None
New! 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 ?
}
Read-Only
Author
Andrew Neil
Posted
20-Jul-2001 17:17 GMT
Toolset
None
New! RE: union, bit field and bdata
http://www.keil.com/support/docs/928.htm
http://www.keil.com/support/docs/1279.htm

And, of course, the C51 User's Guide, C51.pdf

Next Thread | Thread List | Previous Thread Start a Thread | Settings