-
Notifications
You must be signed in to change notification settings - Fork 8
AnduinoEEPROM
The Anduino shield comes equipped with an M24256 32Kb I2C connected EEPROM and corresponding library to provide a simple interface for interacting with the additional storage. This is especially handy since the Arduino Due doesn't ship with onboard standard EEPROM like other Arduino models. Some stats at a glance...
-
32Kb of EEPROM storage
-
64byte Page size
-
1Mhz bus speed
-
4 million write cycles!
Installing the library includes some common operations and procedures around EEPROM and abstracts the details of communicating via I2C
- void begin(void);
- byte write(unsigned int eeaddress, byte data);
- byte read(unisgned int eeaddress);
- int writePage(unsigned int eeaddress, byte* buffer, int pageSize);
- void readPage(unsigned int eeaddress, byte buffer[], int pageSize);
- void printToTerm(unsigned int eeaddress, int numPages);
- void eraseContents(unsigned int eeaddress, int numPages);
- void storeImg(unsigned int eeaddress);
In your sketch be sure to include the EEPROM Library by adding
#include "AnduinoEEPROM.h"
to the top of your sketch as well as
AnduinoEEPROM EEPROM = AnduinoEEPROM();
EEPROM.begin();
to properly create your EEPROM object and initialize the chip.
To get started quickly check out the example sketches available by navigating to the Arduino IDE toolbar, select File>>Examples>>AnduinoEEPROM.
-
Initializes the I2C bus
-
The Anduino Shield is using SDA1 and SCL1 (Wire library utilizes 'Wire1')
-
Sets bus speed to 1Mhz
-
Writes one byte of data to address defined by eeaddress
- The address range of the EEPROM is 0x0000 - 0x7FFF (0-32767)
EEPROM.write(3, 0xFF); //writes 0xFF to address 0x03
- Returns one byte of data located at supplied address
Serial.print(EEPROM.read(3), HEX); //Prints the data stored at address 0x03 to terminal
-
Writes one page sized chunk worth of data starting at the supplied address
-
To accomplish successive page writes just increase eeaddress in pageSize'd increments
-
64byte maximum pageSize
-
Just pass a pointer to your buffer[pageSize] of data to be written
-
Faster than successive write() calls
EEPROM.writePage(0, bufferPtr, 64);
//writes all 64bytes contained in buffer pointed to by bufferPtr to page at address 0
-
Reads one page sized chunk worth of data starting at supplied address
-
Pass the destination buffer[pageSize]
-
64byte maximum PageSize
-
Faster than successive read() calls
/*read each page and store in bufferPage, inc to next page in memory
starting at eeaddress until the requsted numPages have been read*/
for(int i=eeaddress; i<numPages*PAGE_SIZE; i+=PAGE_SIZE)
{
readPage(i, bufferPage, PAGE_SIZE);
}
-
Prints 64byte wide pages of EEPROM to terminal
-
Starts at supplied eeaddress
-
Prints successive pages to terminal for supplied numPages - 512max
-
EEPROM.printToTerm(0, numPages); Abbreviated output: 0x0-0x3F: 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0x... 0x40-0x7F: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x... 0x80-0xBF: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x... 0xC0-0xFF: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x... 0x...
-
Initializes successive pages starting at supplied eeaddress to all 0's
eraseContents(0, 512); //erases entire EEPROM initializing all data to 0x00
- Stores an image supplied in GIMP format to EEPROM parsing the image pixel by pixel
- loadLogoEEPROM example sketch in ArduinoIDE will read the image from EEPROM and display on LCD display