Lab 1: Create the Application

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

1

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

lab1_step4_01.png
Figure 1: Add PIC32MZ W1 Curiosity BSP

2

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

lab1_step4_02a.png
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.

lab1_step4_02b.png
Figure 3: Accept Core module auto-activation
lab1_step4_02c.png
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.

lab1_step4_02d.png
Figure 5: I2C Driver

3

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.

lab1_step4_03a.png
Figure 6: Satisfy I2C Driver with I2C1 PLIB
lab1_step4_03b.png
Figure 7: Connect I2C1 to I2C Driver

Select I2C1 peripheral library and keep the default configuration.

lab1_step4_03c.png
Figure 8: I2C1 Default Configuration

4

Configure Pins for I2C1 peripheral library.

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

lab1_step4_04a.png
Figure 9: Open Pin Configuration

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

lab1_step4_04b.png
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.

5

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.

lab1_step4_05.png
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.