Arduino Playground

November 27, 2010

This is a simple Arduino interface to an SPI EEPROM. I built a small board back in July and soldered a ROM part which I had at hands, Atmel 25*256 with capacity of 32KB.

This is a link to the datasheet.

This particular EEPROM is convinient as it runs on 5V, the level Arduino uses for its periperals.

The board has listed pin numbers to connect:

1 Chip Select, inverted => Arduino any digital pin (SS)
2 Slave Out => Arduino any digital pin (MISO)
3 Write Protect, inverted => Vcc
4 Ground => GND
5 Slave In => Arduino any digital pin (MOSI)
6 Slave Clock => Arduino any digital pin (SCK)
7 Hold, inverted => Vcc
8 Vcc => Vcc

Connect Vcc and GND to Arduino power rails (+5V, GND) and the remaining 4 control signal wires to any Arduino digital pins - they will be specified in software as shown:

// Specify pins and instantiate EEPROM object

#define ssPin	3		// slave device select pin
#define misoPin	4		// master in, slave out pin
#define mosiPin	2		// master out, slave in pin
#define sckPin	5		// slave clock pin

This particular ROM part has a page size of 64 bytes. The setup function accepts optional parameter for any other page size.

The library is maintained at github, this address: https://github.com/gdevic/MySpiEeprom

Note that newer Arduinos have built-in hardware support for SPI; however, it seems that the pins are hard-coded, "On the Arduino Duemilanove and other ATmega168 / 328-based boards, the SPI bus uses pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). On the Arduino Mega, this is 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS)." [link]. This library will work with any Arduino controller with SPI part connected to any pin and also provide option to support multiple rom parts, each of them being simply instantiated as a class in software driver.