EEPROM Driver for AVR with RAM

Posted on Oct 16, 2012

I had been putting off writing a driver for some 24LC64 and 24LC256 EEPROMS I was thinking about using, when I came across a temperature logger application written by Seal Ellis. The Temperature logger was posted on on on January 10, 2002, project ID 49. The original application was written for the ATtiny15, whichhas a small hardware stack, so when extracting the I2C code, I massaged it a little bit to make it more compact when running on processors equipped with a RAM stack while making it a little easier to customize for new applications.

The subroutine, I2CInit, needs to be called during initialization, preferable after the I/O ports are initialized but before calling any I2C read or write routines. I2CInit will set up the I2C I/O pins and initialize the bus. The EEPROM code needs to be customized to deal with the I/O pins being used and the processor clock speed in each particular application. .All constants and registers that need to be modified are found in the I2C Memory Driver section. Check and if necessary, change the I/O assignments to I2CPORT, I2CDDR, I2CPIN, bSDA, and bSCL in the I2C Memory Driver sect Delays to accommodate various bus speed and processor clock rates are controlled by the constant I2CDelayConstant. The device address constant (ADDR24LC64 in this case) needs to match that of the EEPROM being used. The 24LC64, 24LC128. and 24LC256 use address A0 when their address pins are tied low. There are two main subroutines of interest. WriteI2Mem writes the byte contained in register "I2WData" into the EEPROM location pointed to by ZH,ZL. ReadI2Mem reads the byte at the EEPROM location pointed to by ZH,ZL and returns the byte in register "temp". There are no provision within the subroutines to check for invalid addresses.

Leave Comment

characters left:

New Circuits



Popular Circuits

Tone-alert decoder
Direction and speed control for series-wound motors
Flip-Flop Debouncer Switch
Li Ion Battery Charger Circuit Using IC LP2951
lights led circuits schematics
FM Booster Circuit PCB
PRUBY Documentation
MC1411 series Darlington current internal structure of a drive circuit