ds1307_how_to_access_ram
This is an old revision of the document!
How to Access Ram
Each I2C device has an address. The DS1307 chip address is 0x68.
The Ram on the device starts at address 0x08. The first 7 locations are the RTC.
To get to the start of RAM, use the following code:
Wire.beginTransmission(DS1307_ADDRESS); Wire.send(8); Wire.endTransmission();
This will set the I2C address to 0x68, the DS1307 Address.
The second line sets the register index to 8, the start of RAM.
The third line, Wire.endTransmission(); , transmits the sequence.
Subsequent reads from the chip will start at 8. For example, to read 4 bytes from the chip:
Wire.requestFrom(DS1307_ADDRESS, 4);
This will put the 4 bytes into the receive buffer. To fetch the bytes:
while(Wire.available()) // slave may send less than requested { byte c = Wire.receive(); // receive a byte as character Serial.print(c, HEX); // print the character Serial.print(" "); }
ds1307_how_to_access_ram.1315878248.txt.gz · Last modified: 2011/09/12 21:44 by tomgee