Step 2.1: 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.
Select the SERCOM0 Peripheral Library and configure it for the I²C protocol.
- 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.
Note: "Master" and "Slave" terminology has been replaced on this page with the equivalent Microchip terminology "Host" and "Client" respectively.
The mikroBUS socket #2 and socket #3 design schematic for the PIC32CM MC00 Curiosity Nano Evaluation Kit and Curiosity Nano Base Board are shown below.
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.
Select the MHC Pin Settings tab and sort the entries by Ports 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)
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.
Table of Contents