I2C external loopback polling

This example demonstrates I2C communication using polling-based methods between controller (master) and target (slave) devices. The application configures two I2C instances - one as a controller and another as a target - and performs an external loopback test where data sent from the controller is received by the target. The example uses polling methods to check for data availability and transmission completion.

Example Usage

  1. Connect the I2C pins as described in the “External Connections” table.

  2. Build and run the example after connecting to the device.

  3. The application initializes both I2C instances with:

    • Controller configured with address 0x3C as target

    • Target configured with address 0x3C

  4. The controller sends 128 bytes of test data (sequential values 1-128).

  5. The target collects the data using polling mechanisms.

  6. The application polls for transfer completion and verifies that the received data matches the transmitted data.

  7. The example indicates success or failure via console output.

Key features demonstrated

  • I2C controller and target configuration

  • FIFO configuration and usage

  • Polling-based I2C transfers

  • External loopback validation of I2C communication

External connections

Controller (UC2)

Target (UC1)

SDA (PA22)

SDA (PA8)

SCL (PA23)

SCL (PD8)