DS1307 RTC programming - 2. Using the 56 nvSRAM bytes


the ds1307 comes 56 bytes of nvsram.

if remove battery sram dies. 56 bytes survive power off when used
with arduino eeprom. here read , write cares.

code: [select]

void tiny_rtc_ds1307_24c32::readsrambyte(byte baddress, byte *pbvalue)
{
  wire.begintransmission(ds1307_i2c_address);
  wire.write(baddress+8);
  wire.endtransmission();
  uint8_t bret = wire.requestfrom(ds1307_i2c_address, 1);
  *pbvalue = wire.read();
}

void tiny_rtc_ds1307_24c32::writesrambyte(byte baddress, byte bvalue)
{
  wire.begintransmission(ds1307_i2c_address);
  wire.write(baddress+8);
  wire.write(bvalue);
  wire.endtransmission();
}

thanks sharing. want better understand akis_t has provided, see timekeeper register, table 2 on page 8 of:

http://datasheets.maximintegrated.com/en/ds/ds1307.pdf


Arduino Forum > Using Arduino > Programming Questions > DS1307 RTC programming - 2. Using the 56 nvSRAM bytes


arduino

Comments