Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C programming, need help for I2C access ATMEGA+24C16

Status
Not open for further replies.

Kuzito

Newbie level 6
Joined
Nov 5, 2006
Messages
14
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,459
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.

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
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top