Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DS1307 Write Issues

Status
Not open for further replies.

Suraj143

Active Member
Guys in my clock I use a DS1307 chip with PIC.The code works well.

I have two buttons to adjust the time "Hour" & "Minutes"

But sometimes I cannot write to DS1307.But it reads well.The display time is correct.

So after I remove battery & place it back I can write.

Whats the correct way of writing to DS1307?

I use SQW output also to interrupt @ 1 sec.

Do I need to turn off CH (clock Halt bit) or do I need to Stop SQW bit before writing to Hour or Minute registers?After writing registers I clear the seconds registers too.
 
Last edited:
You shouldn't clear the seconds register. The correct way is to write all 8 registers in one go. The time gets written to the actual registers during the ACK. Note that the 8 writes must be in one block and written in less than 1 second.

Mike.
 
Hi mike I need only "Seconds","Minutes" & "Hour" registers.

If I need only above three do I still need to write all 8 registers?

I also show the seconds on the display.So I have to clear the seconds register after I change the time.

Currently I'm doing like this.
*Write Minutes
*Write Hours
*Write Seconds (clear)

You mean to write in this order?

*Write Seconds (clear)
*Write Minutes
*Write Hours

But in both ways the SQW register is operating (ON Mode).
 
Yes, it should work writing seconds mins hours but they must be done in one write.

Mike.
 
Yes, it should work writing seconds mins hours but they must be done in one write.

Mike.

You got my point.Now Only I got it :D upto now I have written in separate writes that is bad.

I'll do in one write & see how it goes :)

Thanks for the idea.
 
Status
Not open for further replies.

Latest threads

Back
Top