Download library here.

The 24LCxx is an I2C EEPROM series of Microchip. With this library it is possible to write and read all the IC's of that series that have a capacity less than 32K. For example the 24LC16 or the 24LC04. There are IC's with a larger capacity but they need another communication protocol. This EEPROM is build up in blocks of 256KByte. The 24LC08 for example has a capacity of 8Kbit, that is 1KByte / 256Byte = 4 blocks.
To select another block, use the command EEPROMSetBlock(>block nr<).

This example toggles a led on the Simplecortex with the reset button. The program starts with reading the EEPROM. If the value is 0, the program inverts it to 255 and otherwise the same way. Then the new value will be written to the EEPROM and the LED.
Note that befor the program starts the value of the EEPROM has to be 0 or 255, else the inversion does not have any sense.


#include "lpc17xx.h"
#include "lpc_types.h"
#include "i2c.h"
#include "gpio.h"
#include "24LC16.h"

int main (void)
    uint8_t var;

    /*Initialize EEPROM on I2C channel 1 and select memory block 0*/

    /*Set on-board led 1,18 as output*/

    /*Read EEPROM and put value in var*/
    var = EEPROMRead(I2C1,0);

    /*Invert var*/
    var = ~var;

    /*Copy value to EEPROM and change port status*/



Copyright 2011. Joomla 1.7 templates - Joomla template maker. The Simplecortex is developed by BRC-Electronics