Pi Spi Eeprom

4
Jotschi's Blog NeXuS Raspberry PI – 25LC010A EEPROM Howto Posted on 6 September, 2012 by Jotschi 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 can be found here. 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: 2. Reboot the PI 3. Install wiringPI as described here. 4. Use the build gpio tool to load and setup SPI 5. Connect the IC as shown in this image: View Raw Code /etc/modprobe.d/raspi-blacklist.conf 1. View Raw Code sudo apt-get install git-core 1. git clone git://git.drogon.net/wiringPi 2. cd wiringPi 3. ./build 4. View Raw Code gpio load spi 1. Raspberry PI – 25LC010A EEPROM Howto | Jotschi's Blog http://www.jotschi.de/?p=784 1 of 4 01/07/2013 08:16 PM

description

spi

Transcript of Pi Spi Eeprom

Page 1: Pi Spi Eeprom

Jotschi's Blog

NeXuS

Raspberry PI – 25LC010A EEPROM Howto

Posted on 6 September, 2012 by Jotschi

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 can be found here.

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:

2. Reboot the PI

3. Install wiringPI as described here.

4. Use the build gpio tool to load and setup SPI

5. Connect the IC as shown in this image:

View Raw Code

/etc/modprobe.d/raspi-blacklist.conf 1.

View Raw Code

sudo apt-get install git-core1.

git clone git://git.drogon.net/wiringPi2.

cd wiringPi3.

./build4.

View Raw Code

gpio load spi1.

Raspberry PI – 25LC010A EEPROM Howto | Jotschi's Blog http://www.jotschi.de/?p=784

1 of 4 01/07/2013 08:16 PM

Page 2: Pi Spi Eeprom

The two resistors are very important because they are used to pullup the SCK and MOSI pin. The eeprom works with 5V or

3.3V. I used 3.3V because the GPIO pins only tolerate 3.3V input. Higher voltage might damage your board.

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

View Raw Code

#DEBUG = -g -O01.

DEBUG = -O32.

CC = gcc3.

INCLUDE = -I/usr/local/include4.

CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe5.

Raspberry PI – 25LC010A EEPROM Howto | Jotschi's Blog http://www.jotschi.de/?p=784

2 of 4 01/07/2013 08:16 PM

Page 3: Pi Spi Eeprom

Sources:

[gist id=3659646 file=rpi_spi_eepromtest.c]

6.

LDFLAGS = -L/usr/local/lib7.

LIBS = -lwiringPi8.

9.

# Should not alter anything below this line10.

###########################################################################

####

11.

12.

SRC = rpi_spi_eepromtest.c13.

14.

OBJ = rpi_spi_eepromtest.o 15.

16.

all: rpi_spi_eepromtest17.

18.

rpi_spi_eepromtest: rpi_spi_eepromtest.o19.

@echo [link]20.

$(CC) -o $@ rpi_spi_eepromtest.o $(LDFLAGS) $(LIBS)21.

22.

.c.o:23.

@echo [CC] $<24.

@$(CC) -c $(CFLAGS) $< -o $@25.

26.

clean:27.

rm -f $(OBJ) *~ core tags rpi_spi_eepromtest28.

29.

tags: $(SRC)30.

@echo [ctags]31.

@ctags $(SRC)32.

33.

depend:34.

makedepend -Y $(SRC)35.

36.

# DO NOT DELETE37.

Raspberry PI – 25LC010A EEPROM Howto | Jotschi's Blog http://www.jotschi.de/?p=784

3 of 4 01/07/2013 08:16 PM

Page 4: Pi Spi Eeprom

Add a comment

This entry was posted in Technik by Jotschi. Bookmark the permalink [http://www.jotschi.de/?p=784] .

0

Raspberry PI – 25LC010A EEPROM Howto | Jotschi's Blog http://www.jotschi.de/?p=784

4 of 4 01/07/2013 08:16 PM