i2cDemo Example

The I2C interrupt example (i2cDemo directory) provides example code for an I2C master writing data to and reading data from an off-chip MCP4725 device with interrupt. The Microchip MCP4725 device is a single channel, 12-bit, voltage output digital-to-analog converter (DAC) with an I2C interface.

The MCP4725 device is available on breakout boards from vendors such as Adafruit and SparkFun. You can connect the breakout board's SDA and SCL pins to a development board.

The code assumes that the I2C block is the only master on the bus, and it sends frames in blocks. When you run it, the application connects to the MCP4725 device and increases the DAC value. It also prints the message Start on a UART terminal.

In this example:
  • void trap() traps entries on exceptions and interrupt events
  • void externalInterrupt() triggers an interrupt event