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
Connect the I2C pins as described in the “External Connections” table.
Build and run the example after connecting the device.
The application initializes both I2C instances with:
Target address set to 0x3C
FIFO enabled with triggers at half-full/half-empty
Interrupt-driven operation
The controller sends test data (128 Bytes) to the target.
The target receives the data using interrupts.
The application verifies that the received data matches the transmitted data.
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) |
Controller (UC2) |
Target (UC1) |
|---|---|
SDA (PA22) (HSECDOCK-85) |
SDA (PC19) (HSECDOCK-99) |
SCL (PA23) (HSECDOCK-88) |
SCL (PC20) (HSECDOCK-107) |