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.

RTC ds1307 run slow!

Status
Not open for further replies.

pyrodigy

New Member
Hi to all!
I am currently having a problem with RTC ds1307.It works so slowly,seconds increments like a minute!
I am using 16f877 and I can read and write minutes,seconds,dates,months and years to RTC via I2C protocol.
But i couldnt find out why ds1307 run slowly:(
I realy need any comments
Thanks
 
Hi guys thanks for your quick responses,
I have attached my schema which i used to run ds1307 with pic.I tried to mention RTC runs slowly as unusual.Exactly seconds increments normally each after 10 seconds so I dont think i am reading wrong register.
In my opinion code works fine,i just got an electrical or xtal based problem.
Thanks
 

Attachments

  • ds1307.JPG
    ds1307.JPG
    67 KB · Views: 3,412
If the crystal is good, it should work as is without problem. Is the back-up battery there? If not, you have to short Vbat to GND.

Also... did you clear the 'Seconds' register bit 7 ... CH bit? i bet on this one ;)
 
Last edited:
mister_e said:
If the crystal is good, it should work as is without problem. Is the back-up battery there? If not, you have to short Vbat to GND.

Also... did you clear the 'Seconds' register bit 7 ... CH bit? i bet on this one ;)
Thank you mister_e for your quick response
I would like to let you know that i use 32.768 kHz crystal to run ds1307,and there is a backup battery in my circuit.
Could you please tell me more about CH bit?Should i clean it when i writing to current date to ds1307?or while reading the date from RTC?
Here is the code which i always use when i writing the current date to RTC
Code:
START_SECONDS		EQU		0x00	;
Thanks
Volkan
 
well, if it increments once every 10 real seconds, I think your code for displaying seconds is broken. the format is binary coded decimal (bcd) with the ones digit in the lower nibble and the 10s digit in the upper nibble. look at your code - some how you are loosing the lower nibble.
 
Last edited:
CH Bit is the bit 7 of the 'seconds' register. It must be clear only once to start the internal oscillator. It's done by writing 0 to 'Seconds' register.

Without your code, it's hard to know what's wrong.
 
mister_e said:
CH Bit is the bit 7 of the 'seconds' register. It must be clear only once to start the internal oscillator. It's done by writing 0 to 'Seconds' register.

Without your code, it's hard to know what's wrong.

yes, he should post the code. but I don't think it will be the high bit of the seconds reg since it appears to be incrementing. however, severely broken code can look like anything!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top