Example: I2C EEPROM interface

Example: I2C EEPROM interface

In this example we consider how to link an 8051 microcontroller to a serial EEPROM using an I2C bus. Note that use of such EEPROMs is a common way of retaining system settings after power is removed: the storage is non-volatile, for a period of around 100 years.

Hardware

The required hardware is illustrated in Figure 23.6.

Note that, in this case, we are not using an open-collector port and do not require pull-up resistors. If you are using more than one I2C device, it is recommended that you adapt the code to work with Port 0 (a trivial change) and use pull-up resistor values calculated as described in ‘Background’.

Software

The required software is contained in Listings 23.4 to 23.6. Note that you will also require the core I2C library from the ‘Solution’ section.

image

image

image

image

image

image

Leave a comment

Your email address will not be published. Required fields are marked *