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

Accesing bit addressable variables

I was wondering what the "best" way to set a bit in a variable declared in the bit addressable area.

Originally I declared each bit as an sbit and therefore can set and clear them as follows

uint8_t bdata status ;
sbit enable = staus ^ 0 ;

enable = 1 ;
enable = 0 ;
I think it looks clearer to do as follows
#define ENABLE 0x01

uint8_t bdata status ;

status |= ENABLE ;
status &= ~ENABLE ;

but I am worried that this could less maintainable because there will be many #defines with the same values but related to different variables and confusion could ensue.

I was wondering what other people do and if there is a standard method for doing this?

Parents
  • "Maybe it has something to do with the way i have defined the variable."

    Or because you are using a C166 compiler as opposed to the (apparent) use of C51 by other posters. In fairness to everyone, your posts did not specify a product and I would hazard a guess that when none is specified, C51 is assumed.

Reply
  • "Maybe it has something to do with the way i have defined the variable."

    Or because you are using a C166 compiler as opposed to the (apparent) use of C51 by other posters. In fairness to everyone, your posts did not specify a product and I would hazard a guess that when none is specified, C51 is assumed.

Children