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 port pins in port(P0,1,2)?

I would like to call function like port(P0,1,2).i want to assign the values of 0 and 1 to P0.1 and P0.2 using that function prototype only...how can i assign the values to port pins.what are the steps i need to follow...

Thanks in advance

chinnaye

Parents
  • You need to start by checking the processor instructions supported by the 8051 processor. Then you would see that not all address ranges can be accessed using an index, where you store the address in a register and perform an access relative to the contents of this register - the available instructions requires the offset to be hard-coded in the instruction.

    So you need to have self-modifying code (which isn't supported by C) to modify the instruction to point at a specific bit in the bit-addressable range. Or you need to perform and/or operation on bytes. Or you need to have a switch statement that contains a case: statement for every bit that the function needs to be able to operate on.

    The 8051 is not a general-purpose architecture, so you need specific knowledge about the architecture to understand the limitations imposed on C programs written for 8051 processors.

Reply
  • You need to start by checking the processor instructions supported by the 8051 processor. Then you would see that not all address ranges can be accessed using an index, where you store the address in a register and perform an access relative to the contents of this register - the available instructions requires the offset to be hard-coded in the instruction.

    So you need to have self-modifying code (which isn't supported by C) to modify the instruction to point at a specific bit in the bit-addressable range. Or you need to perform and/or operation on bytes. Or you need to have a switch statement that contains a case: statement for every bit that the function needs to be able to operate on.

    The 8051 is not a general-purpose architecture, so you need specific knowledge about the architecture to understand the limitations imposed on C programs written for 8051 processors.

Children