User Tools

Site Tools


ds1307_how_to_access_ram

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ds1307_how_to_access_ram [2011/09/12 21:39] tomgeeds1307_how_to_access_ram [2011/09/12 21:44] (current) tomgee
Line 4: Line 4:
 The Ram on the device starts at address 0x08. The first 7 locations are the RTC.\\ The Ram on the device starts at address 0x08. The first 7 locations are the RTC.\\
 {{:rtc_registers.jpg?600|}} {{:rtc_registers.jpg?600|}}
 +
 +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);
 +
 +The above line 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.1315877963.txt.gz · Last modified: 2011/09/12 21:39 by tomgee