Step 3: Identifying and Configuring the I2C Pins
Identifying the Inter-Integrated Circuit (I2C) Pins Using the User Guide
To accurately identify the I2C clock (SCL) and data (SDA) pins on the microcontroller, begin by consulting the schematic diagram provided in the user guide. Within the schematic, locate the sections labeled I2C SCL and I2C SDA.
These labels correspond to the Serial Clock Line (SCL) and Serial Data Line (SDA) of the I2C communication protocol. Carefully trace these labels to their respective connections on the schematic diagram. The schematic will indicate the exact pin numbers on the microcontroller that serve as the I2C clock and data lines.

In the diagram above, the pins are labeled with their respective names. The I2C data line (SDA) is mapped to pin PA12 and the I2C clock line (SCL) is mapped to pin PA13.
After identifying the correct pin numbers, verify that these pins are not allocated to any other functions on the PIC32CM LS00 Curiosity Nano+ Touch Pinout.

Verify the I2C Pins Using Datasheet
Open the "PIC32CM LE00/LS00/LS60 Family Data Sheet". Navigate to the "Pinout and Packaging" section and go to 48-pin VQFN and 48-pin TQFP packages. Refer to Table 4-2 48-pin VQFN/48-pin TQFP I/O PINMUX. Locate PA12 and PA13 in the Pin Name column and verify the presence of serial communication functionalities as specified in the datasheet.
If multiple SERCOM modules are listed and one SERCOM is assigned to a different function, the alternative SERCOM module can be utilized for I2C serial communication.

Configure the Identified I2C Pins
Create an MPLAB® Harmony v3 project using MPLAB X IDE. Refer to Lab 1 for detailed project creation instructions. After the project is created, follow the steps below to configure the I2C pins.
After launching MCC, Configure SERCOM2 as the I2C Peripheral Library. In MCC, under the Device Resources tab, expand Libraries > Harmony > Peripheral > SERCOM. Double-click on SERCOM2 to add SERCOM instance 2 to the project configuration.

Select the SERCOM2 Peripheral Library in the Project Graph. Configuration options will appear on the right side of the interface.
By default, the SERCOM operation mode is set to Universal Synchronous Asynchronous Receiver Transmitter (USART); change the operation mode to either I2C Master or I2C Slave as required. For Lab 2, I2C Master mode is selected. Verify the I2C speed setting; the default speed is used in this configuration.

Open the pin Configuration Options as described previously to access the pin settings.
In the Pin Settings tab, set the I2C_SDA (SERCOM2_PAD0) for PA12 and I2C_SCL (SERCOM2_PAD1) for PA13.

After completing the I2C configuration, generate the project as described in Lab 1. This process creates a Peripheral Library (PLIB) that incorporates the selected settings. Within this library, functions such as SERCOM2_I2C_Read, SERCOM2_I2C_Write, and SERCOM2_I2C_WriteRead are available for reading and writing data using I2C communication.
