Rapid Prototyping a Bluetooth Smart Appliance Control Application on a 32-bit MCU-based Curiosity Nano Evaluation Kit using MPLAB® Harmony v3 Software Framework: Step 2

Last modified by Microchip on 2023/11/09 09:08

Configure I²C Peripheral Library and I²C Pins

Under the Available Components tab, expand Peripherals > SERCOM. 

Double-click on SERCOM0 to add the SERCOM instance 0 to the project.

Add SERCOM instance 0 to the project by double-clicking on SERCOM0​

Select the SERCOM0 Peripheral Library and configure it for the I²C protocol.

Configure SERCOM0 Peripheral Library​

Information
  • The SERCOM0 PORT pins coming to mikroBUS socket #2 and mikroBUS socket #3 as I²C lines from PIC32CM MC00 MCU connect to the Fan and Weather Click boards™.
  • You are using just one I²C peripheral instance in the MCU (SDA and SCL lines), acting as an I²C host to interface with two different I²C clients. One is the Fan Click board, and the other one is the Weather Click board connected through the mikroBUS connectors.
  • The I²C client (Fan Click module and Weather Click module) have different addresses for identification.
  • The SERCOM0 (as I²C) retains the default 100 kHz speed because the Weather Click and Fan Click can operate at 100 kHz I²C speed.
  • The SERCOM0 (as I²C) retains the default 50-100 nanoseconds hold time for Serial Data (SDA) Hold Time because it aligns with the minimum (50 nanoseconds) start hold time in the specification of Click boards.
  • The SERCOM0 (as I²C) retains the default 100 nanoseconds for I²C Trise time because it aligns with the maximum (300 nanoseconds) input rise time in the specification of the Click boards.
Information

Note: "Master" and "Slave" terminology has been replaced on this page with the equivalent Microchip terminology "Host" and "Client" respectively.

Open the Pin Configuration tab by clicking MPLAB® Harmony Configurator (MHC) > Tools > Pin Configuration. 

 Open Pin Configuration from the Tools menu​

The mikroBUS socket #2 and socket #3 design schematics for the PIC32CM MC00 Curiosity Nano Evaluation Kit and Curiosity Nano Base Board are shown below.

Information

Note: The highlighted (encircled red box) I²C lines coming onto the mikroBUS socket #2 and mikroBUS socket #3 are connected to the Fan Click and Weather Click respectively.

Design schematic for the PIC32CM MC00 Curiosity Nano Evaluation Kit and Curiosity Nano Base Board​

Select the MHC Pin Settings tab and sort the entries by Ports names.

Select the Pin Setting tab and sort the entries by Port names​

Now, scroll down to the PA08 and PA09 pins and configure as follows.

  • Configure I²C Clock (SCL) on PA09 (Pin #12)
  • Configure I²C Data (SDA) on PA08 (Pin #11)

Configure PA08 and PA09

Information

This completes the configuration of the I²C peripheral library. The application code will use the I²C PLIB Application Programming Interfaces (APIs) to read the temperature from the Weather Click and send commands to the Fan Click to control the 5V DC fan.