I2C Simple Driver Example Source Code Reference

This file contains the API that implements the I2C simple master driver functionalities.

This file contains sample source codes to demonstrate the I2C SIMPLE Foundation Services APIs.

The example works like this:
  1. 1.In this example, we will use I2C SIMPLE drivers to communicate with EEPROM 24LC256
  2. 2.First, we will write a block of data to EEPROM. Then we will read the data we wrote into it.
  3. 3.We will use UART/EUSART to display what we wrote and read from the EEPROM
Hardware Connections
  1. 1.Connect the 24LC256 EEPROM to the device:
    • Add Pull up resistors as per the 24LC256 data sheet recommendations
    • Have a common ground connected
    • Connect the appropriate SCL and SDA pins
For this example application to work the following needs to be done:
  1. 1.Configure SCL and SDA pins in pin manager (Connected to SCL and SDA of EEPROM 24LC256)
  2. 2.Add Delay Foundation Services library
  3. 3.Configure the I2C Clock frequency to 100 KHz
  4. 4.Add and configure the EUSART/UART module as follows:
    • Enable EUSART: ticked
    • Enable Transmit: ticked
    • Redirect STDIO to USART: ticked
    • Select TX and RX pins in Pin Manager Grid View.
  5. 5.Connect the board to a laptop serial port.
  6. 6.Open a serial port terminal application (i.e. PuTTY or TeraTerm)
  7. 7.Configure the serial port application to the following settings:
    • Baud Speed: same as the UART configuration
    • Data: same as the UART configuration
    • Parity: none
    • Stop bits: same as the UART configuration
    • Flow control: none
    • Receive: Carriage Return
    • Transmit: Carriage Return
    • Local Echo: On
  8. 8.Call I2CSIMPLE_example in the main function.