Microchip® Advanced Software Framework

Quick Start Guide for SERCOM I2C Slave - Basic

In this use case, the I2C will used and set up as follows:

  • Slave mode
  • 100KHz operation speed
  • Not operational in standby
  • 10000 packet timeout value

Prerequisites

The device must be connected to an I2C master.

Setup

Code

The following must be added to the user application:

A sample buffer to write from, a sample buffer to read to and length of buffers:

Address to respond to:

Globally accessible module structure:

Function for setting up the module:

Add to user application main():

Workflow

  1. Configure and enable module.
    1. Create and initialize configuration structure.
    2. Change address and address mode settings in the configuration.
    3. Initialize the module with the set configurations.
    4. Enable the module.
  2. Create variable to hold transfer direction.
  3. Create packet variable to transfer.

Implementation

Code

Add to user application main():

Workflow

  1. Wait for start condition from master and get transfer direction.
  2. Depending on transfer direction, set up buffer to read to or write from, and write or read from master.