Software conrolled Port_x_7 usage while LCD user module using Port_x

Question: Why Pin7 of Port2 always being drived to low even I pull it high in my code if LCD user module using Port2?

 

Answer:

It is not recommended to use the port assigned to LCD for any other applications. However, if you want to use the pin 7 of port x which used by LCD user module, you need to update pin Px.7, please update Port_x_Data_SHADE variable by setting or clearing the 7th bit (depending what you want to do) and later copy the variable content to PRTxDR, a simple example as below:

//declare this before main.
extern BYTE Port_x_Data_SHADE;

//update the shadow register before writing to port.
Port_x_Data_SHADE ^= 0x80;
PRTxDR ^= Port_x_Data_SHADE;


Also, it would be a good idea to move the software controlled pin to another port and use Px7 as a global input or output if demanded.