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 set and retrieve Portbits in uVision C

How can I set and retrieve bitwise in uVision C? Similar to assembler P1.0 addresses Bit0 in Port P0.
I could not find any possiblility to do so unless I take the usual Bitaddressing techniques (masking and shifting)

Please answer to andreas.alef@web.de

Regards,

A. Alef

Parents
  • Robert, I dont't understand that.

    sbit P0_0 = P0^0;

    With P0 I identify Port 0 as ist ist defined in <reg515c.h>. Ok: I want to set Bit 0. So that is for the name I chose.

    If I want to set Bit0 I can do it in C like
    P0 = 0x01;
    or if I want to let the other 7 Bits as they are:
    P0 = ( P0 | 0x01 );
    in Assembler it would be much easier:
    P0.0 = 1
    I understand your code obviously that I can set and address one bit in P0 with ^ (that is in my opinion exclusive or).

    If I want to set Bit0 of P0, I can take
    P0_0 = 1; or
    P0 = P0 ^ 1; // for the 0th bit
    P0 = P0 ^ 5; // for the 4th bit
    ???

Reply
  • Robert, I dont't understand that.

    sbit P0_0 = P0^0;

    With P0 I identify Port 0 as ist ist defined in <reg515c.h>. Ok: I want to set Bit 0. So that is for the name I chose.

    If I want to set Bit0 I can do it in C like
    P0 = 0x01;
    or if I want to let the other 7 Bits as they are:
    P0 = ( P0 | 0x01 );
    in Assembler it would be much easier:
    P0.0 = 1
    I understand your code obviously that I can set and address one bit in P0 with ^ (that is in my opinion exclusive or).

    If I want to set Bit0 of P0, I can take
    P0_0 = 1; or
    P0 = P0 ^ 1; // for the 0th bit
    P0 = P0 ^ 5; // for the 4th bit
    ???

Children