Hi
Each device you connect to a I2C bus has a 7 bit device address that is set from the factory, some chips has address pins that can be grounded or tied to VDD for additional addressed. Example:
Eeprom has 1010000 as the generic address with all address pins grounded but you can have many EE2 on the same I2C line if each chip has it's own address. 1010000, 1010001,1010010,1010011 and so on, in the datasheet for each component it is stated how many you can have on the same I2C bus.
The address to DS1307 is 11010000 7 bits and the last bit is used by PBP to set read or write. Let us say we have 3 chips on one I2C bus, one eeprom, one RTC and one sound chip. The device id is as below.
EE2=%10100000
RTC=%11010000
ISD=%10000000
To write the the RTC do like this:
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[0,0,0,0,0,0,0,0]
I2C_Adr_W=0
I2CREAD SDA,SCL,EE2,I2C_Adr_W,[I2C_Data(0),I2C_Data(1),I2C_Data(2),I2C_Data(3)]
as long as the device ID are different you can have as many chips as you like on the same I2C lines (more or less anyway)
Look at http://www.8052.com/sbc/schematics/DS1307.pdf PAGE 8 and you can see what the datasheet has to say about this.
Understand?




Bookmarks