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
  • As with any other variable in 'C', you have to define the bit variable first; only then you can you use it

    sbit P0_0 = P0^0;
    Defines a bit variable called P0_0, located at bit zero of P0.

    You can now use P0_0 to access bit 0 of port 0:
    If you put P0_0 on the right-hand side of an assignment, you will read its value;
    If you put P0_0 on the left-hand side of an assignment, you will set its value.

    It's all quite simple, really!

Reply
  • As with any other variable in 'C', you have to define the bit variable first; only then you can you use it

    sbit P0_0 = P0^0;
    Defines a bit variable called P0_0, located at bit zero of P0.

    You can now use P0_0 to access bit 0 of port 0:
    If you put P0_0 on the right-hand side of an assignment, you will read its value;
    If you put P0_0 on the left-hand side of an assignment, you will set its value.

    It's all quite simple, really!

Children