I2C external loopback interrupt

This example demonstrates I2C communication using interrupt-driven controller (master) and target (slave) operations. The application configures two I2C instances (controller and target) and performs an external loopback test where data sent from the controller is received by the target. The transfer uses interrupts to manage the data flow, including TX, RX, and FIFO interrupts.

Example Usage

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

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

  3. The application initializes both I2C instances with:

    • Target address set to 0x3C

    • FIFO enabled with triggers at half-full/half-empty

    • Interrupt-driven operation

  4. The controller sends test data (128 Bytes) to the target.

  5. The target receives the data using interrupts.

  6. The application 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 with FIFOs

  • Interrupt-driven I2C transfers

  • Internal Pull Up Logic configuration using sysconfig

  • FIFO trigger management (1/2 empty for TX, 1/2 full for RX)

  • External loopback validation of I2C communication

External connections

Controller (UC2)

Target (UC4)

SDA (PA22)

SDA (PA9)

SCL (PA23)

SCL (PA10)