Respectable colleagues, how to read a value of a BIT from value of a BYTE variable in Keil C ? For example: X=(Byte1.Bit7*4)+(Byte1.Bit6*2) Thanks in advance. With best regards, Dragan Kujovic
You need to create your variable in BDATA zone and defined its bits : char bdata BYTE; sbit Bit0 = BYTE ^ 0; sbit Bit1 = BYTE ^ 1; sbit Bit2 = BYTE ^ 2; sbit Bit3 = BYTE ^ 3; sbit Bit4 = BYTE ^ 4; sbit Bit5 = BYTE ^ 5; sbit Bit6 = BYTE ^ 6; sbit Bit7 = BYTE ^ 7; Then you'll be able to access each bit individually. nb:you need to use a type cast (int) to multiply a bit by a number int X=(int)Bit7*4 + (int)Bit6*2; Gilles