SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By rdlockrey
#193022
I am building a clock using an arduino UNO with a DS1307 RTC. Its been really no issues until I tried to read the pulse, or manupulate the bytes I need to compare

First want to read the pulse & flick an LED (1khz) , the module has a SQ output, that I can read with INT0 but im not sure about the exact requirements, I havent used interupts with arduino yet so im cautious about firing any

the second is setting/reading the "trickle charge" bit on the DS1307, Im not using a rechargable battery so I want to make sure its disabled, the two sources I reviewed conflict that its disabled at startup, Im not quite familiar with the format of these DS1307 commands so again Im cautious

Can anyone perhaps give an example sketch that,

a) Flicks onboard LED(13) on a 1Khz DS1307 pulse
b) Set the "trickle charge" option byte = 1 or 0
c) Read the trickle charge byte status = 1 or 0

I have tried various methods but havent quite managed to get this part, Im just not doing something right.

As far as the trickle charge, from what I understand there is a write protect bit that has to be set first, but then there is two registers 8Eh & 90h that seem related to this 7th bit , the documentation has
Code: Select all
// 1 = Write Protect, 0 = enabled
#define DS1302_WP DS1302_D7   

//  enable what?
#define DS1302_ENABLE            0x8E

// for trickle charge
#define DS1302_TRICKLE           0x90

I tried to implement the commands, in the following manner

Code: Select all
  // Write Protect
DS1302_write (DS1302_ENABLE, 0);

// Trickle Charger.
DS1302_write (DS1302_TRICKLE, 0x00)

between passing these variables Im not getting it, the RTC is working great its me thats not working right, can anyone help here, Im not going to dump 1000 lines of code here just for that, the basic example included to set the DS1307 clock would be fine for the example.

thanks in advance;