Kuzito
Newbie level 6
atmega 24c16
Hello all,
Im beginner and try to connect I2C 8bit serial eeproms 24C02 and 24C16 to ATMEGA16.
There is code and work great with 24C02 because this eeprom have addresses from 0x00 to 0xFF.
I need help how to read from 8bit serial eeprom 24C16 if address is over 0xFF - 0x120 in example.
For 16bit serial eeproms I send LOW and HIGH address and work with next code:
Thanks in advance,
Kuzito
Hello all,
Im beginner and try to connect I2C 8bit serial eeproms 24C02 and 24C16 to ATMEGA16.
There is code and work great with 24C02 because this eeprom have addresses from 0x00 to 0xFF.
Code:
#define EEPROM_BUS_ADDRESS 0xa0
eeprom_read_8bit(unsigned char address)
{
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS | 1);
data=i2c_read(0);
i2c_stop();
}
I need help how to read from 8bit serial eeprom 24C16 if address is over 0xFF - 0x120 in example.
For 16bit serial eeproms I send LOW and HIGH address and work with next code:
Code:
eeprom_read_16bit(unsigned char address_high, unsigned char address_low)
{
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address_high);
i2c_write(address_low);
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS | 1);
data=i2c_read(0);
i2c_stop();
}
Thanks in advance,
Kuzito