Raspberry PI - 25LC010A EEPROM Howto

This article will explain how to get a SPI connection working using the Raspberry PI GPIO pins.

Hardware:

I used the Adafruit pi cobbler to connect the GPIO header with my breadboard. The 25LC010a eeprom chip is a small eeprom chip. The datasheet: http://ww1.microchip.com/downloads/en/devicedoc/21832c.pdf.

Software:

I used the default raspbian image for the raspberry pi. The wiringpi toolchain contains some neat little programs and libraries to get I2C and SPI working with the raspberry pi.

  1. Disable the blacklist by adding a # in front of each line because you will need the SPI kernel module:

/etc/modprobe.d/raspi-blacklist.conf
  1. Reboot the PI

  2. Install wiringPI as described here.

sudo apt-get install git-core
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
  1. Use the build gpio tool to load and setup SPI

gpio load spi
  1. Connect the IC as shown in this http://twitpic.com/arlj3z" alt="Just got SPI communication with an 25lc010a and my raspberry …​ on Twitpic"> <img src="http://twitpic.com/show/thumb/arlj3z.jpg" width="150" height="150" alt="Just got SPI communication with an 25lc010a and my raspberry …​ on Twitpic">

  2. Compile the source file. You can use this make file:

#DEBUG  = -g -O0
DEBUG   = -O3
CC      = gcc
INCLUDE = -I/usr/local/include
CFLAGS  = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe

LDFLAGS = -L/usr/local/lib
LIBS    = -lwiringPi

# Should not alter anything below this line
###############################################################################

SRC     =       rpi_spi_eepromtest.c

OBJ     =       rpi_spi_eepromtest.o

all:            rpi_spi_eepromtest

rpi_spi_eepromtest:        rpi_spi_eepromtest.o
        @echo [link]
        $(CC) -o $@ rpi_spi_eepromtest.o $(LDFLAGS) $(LIBS)

.c.o:
        @echo [CC] $<
        @$(CC) -c $(CFLAGS) $< -o $@

clean:
        rm -f $(OBJ) *~ core tags rpi_spi_eepromtest

tags:   $(SRC)
        @echo [ctags]
        @ctags $(SRC)

depend:
        makedepend -Y $(SRC)

# DO NOT DELETE

Sources: rpi_spi_eepromtest.c

{% gist 3659646 %}

raspberry pi spi 25LC010a schem