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

How to read a Bit from a Byte ?

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

Parents
  • Don't forget those &ltpre&gt and &lt/pre&gt tags when posting code:

    // main.h

    #define OUTPUT 1
    #define INPUT  0
    
    #define HIGH 1
    #define LOW  0
    
    sfrbit P_TEST  _atbit(P2,10);
    sfrbit DP_TEST _atbit(DP2,10);
    
    //main.c
    void main( void )
    {
       DP_TEST = OUTPUT;
       P_TEST  = HIGH;
       _nop();
       P_TEST  = LOW;
    
       DP_TEST = INPUT;
       if (P_TEST == HIGH) 
       {
          /* do stuff */
       }
    }
    

Reply
  • Don't forget those &ltpre&gt and &lt/pre&gt tags when posting code:

    // main.h

    #define OUTPUT 1
    #define INPUT  0
    
    #define HIGH 1
    #define LOW  0
    
    sfrbit P_TEST  _atbit(P2,10);
    sfrbit DP_TEST _atbit(DP2,10);
    
    //main.c
    void main( void )
    {
       DP_TEST = OUTPUT;
       P_TEST  = HIGH;
       _nop();
       P_TEST  = LOW;
    
       DP_TEST = INPUT;
       if (P_TEST == HIGH) 
       {
          /* do stuff */
       }
    }
    

Children
No data