Hi..
I have done my interfacing of 24C512 with 89c55, Reading writing everything working fine..
But the problem is i tried to write alphabet on a particular location; say 0x00A0... writing done successfully; and when i tried to read it back instead of 0x00A0, same data is available at 0x01A0,0x02A0,... like that...
Please help me to resolve this problem..
eeprom routines are given..
Code:
#include "ports.h"
#include "eeprom.h"
#include "i2c.h"
#include "lcd.h"
#define EEPROMS_ID 0xA0 /* Microchip 24xx512 */
unsigned char EEPROM_get(unsigned int addr)
{
unsigned char dat;
I2C_start(); // Start i2c bus
msdelay(2) ;
I2C_write(EEPROMS_ID); // Connect to EEPROM
I2C_write(addr&0xF0); // Request RAM address (Hight byte)
I2C_write(addr&0x0F); // Request RAM address (Low byte)
I2C_start(); // Start i2c bus
msdelay(2) ;
I2C_write(EEPROMS_ID+1); // Connect to EEPROM for Read
dat = I2C_read(); // Receive data
I2C_noack();
msdelay(2) ;
I2C_stop(); // Stop i2c bus
return dat;
}
void EEPROM_set(unsigned int addr, unsigned char val)
{
I2C_start();
msdelay(2) ;
I2C_write(EEPROMS_ID);
I2C_write(addr&0xF0);
I2C_write(addr&0x0F);
I2C_write(val);
msdelay(2) ;
I2C_stop();
}