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

port setting

Hi,
I want to use port 2 of 167 on MCB net board for two peripherals, one for keyboard interface and other for lcd interface.
Please suggest some code on how to access the same port in parts.
regards
Rajesh

Parents
  • There's no problem in reading the port in parts. To write to parts of the port you could emulate BFLD instruction by using bitwise OR and AND operations. For example, a way to set the upper 8 bits without affecting the lower 8:

    void SetUpperByte(unsigned char byte)
    {
    P2 = (P2 & 0xFF) | ( (unsigned int)byte << 8 );
    }

Reply
  • There's no problem in reading the port in parts. To write to parts of the port you could emulate BFLD instruction by using bitwise OR and AND operations. For example, a way to set the upper 8 bits without affecting the lower 8:

    void SetUpperByte(unsigned char byte)
    {
    P2 = (P2 & 0xFF) | ( (unsigned int)byte << 8 );
    }

Children