i programming "tiny rtc ds1307 " sold on ebay.
it has 2 chips, 1 maxim ds1307. have questions not clear manual.
1) if try start/stop clock need write register 0 seconds register. if zap lose seconds count. presume implied when stop, not care seconds count is, , when start, should send new, valid seconds count.
but if instead wanted use stopwatch, you'd need stop , start while maintaining seconds count. have therefore written stop() , start() functions first current value of seconds subsequent write not trash seconds count. works requires transfers on i2c bus. have got right or missing clever trick? here stop , start code:
it has 2 chips, 1 maxim ds1307. have questions not clear manual.
1) if try start/stop clock need write register 0 seconds register. if zap lose seconds count. presume implied when stop, not care seconds count is, , when start, should send new, valid seconds count.
but if instead wanted use stopwatch, you'd need stop , start while maintaining seconds count. have therefore written stop() , start() functions first current value of seconds subsequent write not trash seconds count. works requires transfers on i2c bus. have got right or missing clever trick? here stop , start code:
code: [select]
void tiny_rtc_ds1307_24c32::stop()
{
wire.begintransmission(ds1307_i2c_address);
wire.write(0);
wire.endtransmission();
uint8_t bret = wire.requestfrom(ds1307_i2c_address, 1);
byte breg0 = wire.read();
breg0 |= 0x80;
wire.begintransmission(ds1307_i2c_address);
wire.write(0);
wire.write(breg0);
wire.endtransmission();
}
void tiny_rtc_ds1307_24c32::start()
{
wire.begintransmission(ds1307_i2c_address);
wire.write(0);
wire.endtransmission();
uint8_t bret = wire.requestfrom(ds1307_i2c_address, 1);
byte breg0 = wire.read();
breg0 &= 0x7f;
wire.begintransmission(ds1307_i2c_address);
wire.write(0);
wire.write(breg0);
wire.endtransmission();
}
what expect happen when seconds register rolls on zero? or timings going less minute?
Arduino Forum > Using Arduino > Programming Questions > DS1307 RTC programming - 1. stopping starting
arduino
Comments
Post a Comment