On the board I use, I have used RG7 for I2C SDA signal,
both bitbanging as a general purpose I/O, and using the peripheral.
It works for me:
TRISGbits.TRISG7 = 1; /* This is same as reset default. */
ANSELGbits.ANSG7 = 0; /* This is needed to enable digital input buffer. */
Pin RD0 is part of a Port that have all pins Digital-Only, so all pins on port D have digital input enabled always.
Port G have some pins that may be used for Analog inputs, and some pins that are Digital-Only.
There is ANSELG register that disable Digital input amplifiers, when analog input is used.
Since the Pin may be connected to a analog input signal with any voltage within the power supply range,
digital inputs must be disabled when the chip is Reset.
Reset state of registers are documented in the datasheet.
TABLE 12-15: PORTG REGISTER MAP FOR 100-PIN, 124-PIN, AND 144-PIN DEVICES ONLY
Reset values are in the very righthand column.
Description is in chapter 12 I/O Ports,
section 12.1.2 CONFIGURING ANALOG AND DIGITAL PORT PINS
post edited by Mysil - 2019/04/23 10:08:32