3 I2C Host Configuration

3.1 Builder: Add I2C Host Component

  1. Application Builder: Click 'Add Component'.
  2. Filter on 'I2C Host' then click the icon to add the I2C_Host Driver.
    Tip: There are a number of I2C off-chip drivers, such as I2C EEPROM AT24CM02 and I2C Temp Sensor MCP98xx, providing more specific support for these client devices.
    Tip: The I2C Host Example shows up as a loaded module, since it is already added to the project.

3.2 Builder: Select I2C PLIB

  1. Next, click Add Dependency to select.
    Tip: For AVR, the Two Wire Interface (TWIx) implements the I2C protocol.
CAUTION: If already added to the project, the I2C PLIB may not be in its default configuration. A component's configuration can be reset as follows:
  1. Click Register Initialization.
  2. From Track Changes, click 'Reset to MCC defaults'.
  3. Confirm that all user changes will be reset.

3.3 Set I2Cx_Host Custom Name to I2C_Host

  1. Click the Custom Name field and remove any numbering from the Peripheral Library (PLIB), setting the value to I2C_Host.
    Tip: Setting the Custom Name to a known value will set the name of the i2c_host_interface_t structure. It ensures that the generated example code will match that in the example. See below the code completion from MPLAB® X IDE.