Exercise 15: EEPROM and Driver Access

Goal:

The goal of this exercise is twofold: First we will learn about an EEPROM, a Electrically Erasable Read Only Memory. These devices are often used in instruments to store calibration values or configuration parameters. EEPROMs can usually be read byte by byte but can be erased and written only in blocks.

The at24c32 EEPROM is mounted together with the DS1307 RTC on the Tiny RTC module (chip on the right). The Tiny RTC module therefore responds to 2 I2C addresses. You find these 2 addresses with the i2cdetect command and you can figure out from the data sheets which of the addresses corresponds to which chip.

rtc.png

Exercise 1: Read the EEPROM

The at24c32 is a 32 kBit device and can therefore store a total of 4096 bytes (4096 * 8 = 32 kBit). Like the DAC it is an I2C device. To make things easier for you, again a library is supplied.

The documentation of the library is again generated from the source code and can be found at the URL:

https://dcsit.twiki.ucc.edu.gh/html/libDoc/at24c32

This one is an exercise for detectives: There is a secret message hidden in the EEPROM and your job is to uncover the mystery. So… Sherlock Holmes and Dr. Watson: show your talents and find out the contents of the message.

Exercise 2: Write the EEPROM

Prepare a buffer with some data to be written to the EEPROM. Use your previous program to read these data back. Power down the Raspberry Pi, wait a minute and then switch it back on again. Verify that you can still read back the data.

Exercise 3: Write an access library

The full description on how to access I2C devices through the driver directly is found here.

Separate out the open, close, read, write … functions into individual files. Rewrite your programs such that you call these generic functions, which can be re-used by other programs.

These are the functions that should be available:

  • at24c32Open

  • at24c32Close

  • at24c32Read

  • at24c32Write

  • at24c32Debug (switching debugging information on or off)

-- Uli Raich - 2017-08-21

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng rtc.png r1 manage 1118.1 K 2017-10-25 - 18:06 UnknownUser  
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2017-11-08 - uli
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback