varible bit handilling

Status
Not open for further replies.
you can do this but using this formula

Code:
unsigned char a;
sbit b=P1^0;

in case of using 8051 micro-controller
 

I prefer perform this test by MARCO comand, this way :

Code:
#define a_BIT0 ( a & 0x01 )     ; declaration
#define SET_a_BIT0 ( a |= 0x01 )   ; declaration
#define CLR_a_BIT0 ( a &= 0x01 ) ; declaration

if ( a_BIT0 ) { do_somethig }   ; evaluation

This implementation allows further compatibility with other compilers which doesn´t suport C language non-standard sbit comand .





+++
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…