uVision 5 - 8051F580 compiler --> macro to make P4 bit addressable

any macros to make P4 bit addressable?

thank you

Fausto Bartra

Parents
  • The SFR P4 is at address 0xB5. This address is not bit-addressable. You can only set or clear bits by using AND / OR operators that modify the whole SFR with a Read-Modify-Write instruction. Example:

    P4 |= 0x01;  // set bit P4.0
    P4 |= 0x02;  // set bit P4.1

    P4 &= 0xFE;  // clear bit P4.0
    P4 &= 0xFD;  // clear bit P4.1

    If you like, you can define macros for such expressions, but we don't have predefined ones.

Reply
  • The SFR P4 is at address 0xB5. This address is not bit-addressable. You can only set or clear bits by using AND / OR operators that modify the whole SFR with a Read-Modify-Write instruction. Example:

    P4 |= 0x01;  // set bit P4.0
    P4 |= 0x02;  // set bit P4.1

    P4 &= 0xFE;  // clear bit P4.0
    P4 &= 0xFD;  // clear bit P4.1

    If you like, you can define macros for such expressions, but we don't have predefined ones.

Children