You should NEVER do whole Port operations that affect an entire Port when that Port has mixed I/O on it. That's just bad programming - so don't do it. You end up switching Inputs into Outputs and vice versa. PIC Inputs for example are normally high impedance, setting them to Output for example, shorts out their feed signals or worse applies voltages upstream into those circuits that shouldn't have voltages applied directly into their outputs.