# Basic TWI EEPROM Project 1.4

## Purpose

This example program demonstrates how to use the TWI peripheral of an AT91 microcontroller to access an external serial EEPROM chip.

## Hardware Requirements

This package can be used with any of the AT91 Evaluation Kits except the AT91CAP9-STK.

An external serial EEPROM must be connected to the TWI bus of the microcontroller. For further information on this topic, please refer to the following application note: Using the Two-wire interface (TWI) in Master Mode on AT91 Microcontrollers.

Pay particular attention to the fact that on some boards, such as the AT91SAM7S-EK, there is no pull-up on the TWI bus: they must be added externally.

## Description

This software performs simple tests on the first and second page of the EEPROM:

- Sets both pages to all zeroes
- Writes pattern in page #0 (polling)
- Reads back data in page #0 and compare with original pattern (polling)
- Writes pattern in page #1 (interrupts)
- Reads back data in page #1 and compare with original pattern (interrupts)

## Usage

1. Compile the application.
2. Connect the DBGU port of the evaluation board to the computer and open it in a terminal.

- Settings: 115200 bauds, 8 bits, 1 stop bit, no parity, no flow control.

3. Download the program inside the evaluation board and run it. Please refer to the SAM-BA User Guide, the GNU-Based Software Development application note or to the IAR EWARM User Guide, depending on your chosen solution.
4. Upon startup, the application will output the following line on the DBGU:

   > `-- Basic TWI EEPROM Project 1.4 --
   > `

5. The following traces detail operations on the EEPROM, displaying success or error messages depending on the results of the commands.

###### Atmel Corporation ©2008