Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TWI EEPROM Example

Introduction

The application demonstrates how to use the SAM TWI driver to access an external serial EEPROM chip.

Requirements

This package can be used with the following setup:

  • SAM3X evaluation kit
  • SAMG53 Xplained Pro kit
  • SAM4N Xplained Pro kit
  • SAMG55 Xplained Pro kit

Main files:

Description of the Example

Upon startup, the program configures PIOs for console UART, LEDs and TWI connected to EEPROM on board. Then it configures the TWI driver and data package. The clock of I2C bus is set as 400kHz. After initializing the master mode, the example sends test pattern to the EEPROM. When sending is complete, TWI driver reads the memory and saves the content in the reception buffer. Then the program compares the content received with the test pattern sent before and prints the comparison result. The corresponding LED is turned on.

On SAM Xplained Pro, the EEPROM is simulated though the twi_slave_example, which means 2 SAM Xplained Pro boards are required to run this example. One board executes this example as the twi master and another runs twi_salve_example as the simulated EEPROM. The TWI PINs and GND PIN should be connected between these 2 boards. More information of the simulated EEPROM implementation can be referred in the description of twi_slave_example.

Compilation Info

This software was written for the GNU GCC and IAR EWARM. Other compilers may or may not work.

Contact Information

For further information, visit Microchip.
Support and FAQ: https://www.microchip.com/support/