i m working in C using Keil 3.55a
how can i define a one bit variable
and how can i compare two bits using if
how can i set or clear Bit
and how can i get the compliment of one byte or one bit, like in ASM CPL A or CPL c
1.how can i define a one bit variable A:
Use #define
#define glcd_SCK 4 #define glcd_SDIN 3 #define glcd_DC 2 #define glcd_SCE 1 #define glcd_RST 0
2.How can i compare two bits using if A:
if(bit1 operator bit2)
3.How can i set or clear Bit A:
bit=0; // for clearing bit=1; // for setting
4.How can i get the compliment of one byte or one bit, like in ASM CPL A or CPL c A: Use ^ operator.
byte^=(1<<bit_pos); // complements the bit in the "bit_pos" bit position. bit=(~bit); // complements the bit
sorry for wrong answer, The answer for the 1st one should be the following:
sbit lcd_SCK=P0^4; sbit lcd_SDIN=P0^3; sbit lcd_DC=P0^2; sbit lcd_SCE=P0^1; sbit lcd_RST=P0^0;
sbit is for single bit declaration.
regards, yateesh k
I agree with Neil.
Incorrect! That does not define one-bit variables!
It does not, in fact, define any variables at all!
Neil,
Sorry for wrong post, In my next post I have tried to regret that.