Lab 1: Create the Application

Step 4: With MHC, Configure I2C Driver, PLIB, Pins and Harmony Core


In the Available Components tab, expand Board Support Packages (BSPs) and add PIC32MZ W1 Curiosity BSP with a double click.

Figure 1: Add PIC32MZ W1 Curiosity BSP


Add the I2C module under Available Components > Harmony > Drivers > I2C.

Figure 2: Add I2C Driver

Accept the Core module auto-activation prompt. Since we will not use FreeRTOS in Lab 1, defer enabling this component for now. Once you are done, the module will be visible in the Project Graph pane.

Figure 3: Accept Core module auto-activation
Figure 4: Defer FreeRTOS activation

I2C Driver and Core Component are now part of the Project Graph. The PLIB Used field will be auto-populated when I2C peripheral library is connected.

Figure 5: I2C Driver


Connect I2C Driver with I2C1 peripheral library.

Right-click on the red diamond next to DRV_I2 to bring up a list of Satisfiers that can be used to attach to this component. Select the I2C1 peripheral library.

Figure 6: Satisfy I2C Driver with I2C1 PLIB
Figure 7: Connect I2C1 to I2C Driver

Select I2C1 peripheral library and keep the default configuration.

Figure 8: I2C1 Default Configuration


Configure Pins for I2C1 peripheral library.

Open the Pin Configuration pane by navigating to MHC > Tools > Pin Configuration.

Figure 9: Open Pin Configuration

Select the Pin Table tab and scroll down to the I2C1 module as shown below.

Figure 10: Enable I2C1 pins

Enable I2C Data (I2C_SDA) on RA5 (pin #B15)
Enable I2C Clock (I2C_SCL) on RA4 (pin #A16)

Go back to the Project Graph.


Select and configure Core Component.
Provide the name app_sensor to the current application under Generate Harmony Application Files > Application Configuration > Application 0 Configuration > Application Name.

Figure 11: Set the app_sensor name

This completes the configurations of the I2C Driver, I2C1 peripheral library, and the Core component. The application code will use the I2C Driver APIs to read the value from the temperature sensor.

Next Step >

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.