2.9 SDA and SCL Pins

The Serial Data (SDA) and Serial Clock (SCL) pins are used by the I2C module to control the I2C bus lines. Unlike previous versions of the MSSP, the SCL and SDA pins must be configured manually in open-drain operation by setting the appropriate bits in the associated port’s Open-Drain Control register (ODCON). Also unlike previous versions of the MSSP, the port’s Direction Control register (TRIS) must have the SDA and SCL pins configured as outputs by clearing the appropriate TRIS bits. Finally, slew rate control, internal pull-up resistor selection, and input threshold levels for each pin can be configured using the RxyI2C I2C Pad Control register.

Important: Note that previous MSSP modules have recommended using external pull-up resistors rather than the internal weak pull-ups. However, the internal pull-ups located on the dedicated I2C pins may now be used, depending on the bus transmission frequency and capacitance. The internal pull-ups can be configured in the RxyI2C register.

The SDA and SCL pins are typically assigned to two I/O port pins, and must be enabled using the Peripheral Pin Select (PPS) module. The PPS module has two dedicated I2C input registers: I2CxSCLPPS, which defines the SCL input pin, and I2CxDATPPS, which defines the SDA input pin. SDA and SCL outputs are also defined via the PPS module. The outputs use the RxyPPS registers to define the signal the pin will output.

Important: Note that both the SDA and SCL inputs and outputs must be defined, and must be assigned to the same pins. For example, if the SDA pin is assigned to pin RC4, both the I2CxDATPPS and the RC4PPS registers must be mapped to pin RC4. If both input and output signals are not mapped to the same pin, or if one of the signals are not mapped at all, no communication will take place.

The PPS module also allows for alternate pins to be used instead of the default pin locations. If an alternate pin location is desired, simply load the appropriate PPS registers with the new location.

Important: Note that some devices allow digital peripherals to be relocated to any pin, while other devices only allow the digital peripherals to be moved to pins within two I/O ports. Please refer to the device data sheet’s PPS chapter for more details. Also, if the I2C pin locations are moved from the default pins, the new locations may not be configured for I2C levels, and would require the open-drain, slew rate, and input threshold control registers to be configured for I2C levels, and the bus may require external pull-up resistors since the weak pull-ups of non-I2C pins are not suitable for communication.