Real Time Clock Interfacing

DS1307, a 64 x 8, Serial, I2C Real-Time Clock, is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. It a product of Maxim/Dallas Semiconductor, see the product page.
This is an example how to interface DS1307 with 8051. I use SDCC as C Compiler. My schematic is shown below.
Schematic: 8051 interface to DS1307
Datasheet
- DS1307 [pdf]
Source Code (For SDCC)
- ds1307.h
- test_ds1307.c
Related Links
- DS1307 Products Page
- Interfacing I2C RTC (DS1307) with MCS-51 (KEIL C51)










File “test_ds1307.c” ,Not found.
Pls upload it again.
Thanks…
I appreciate to let me know that.
Now the problem has been resolved.
i try the source code and it’s OK.. but the display at LCD is standstill… no counting on time.. it’s display
Date: 01/01/…
Time: 00:00:80
can you help me!!!
-m@di
-m@di
I think, you should recalculate the delaying time for LCD command. It needs 2 ms for each command. My board uses 18.432 MHz of XTAL. So, you should change the number of iterations in LCD delaying function to fit to your XTAL.
Hello MCU Programmer,
great work,
can i use this project with DS89C450 MCU
arun(india)
Yes, sdcc supports DS89C450 MCU, (see here for reference).
But, you have to change #include <p89v51rd2.h> to appropriate header file for your MCU.
“I think, you should recalculate the delaying time for LCD command. It needs 2 ms for each command. My board uses 18.432 MHz of XTAL. So, you should change the number of iterations in LCD delaying function to fit to your XTAL.”
I was change my delay but still got same result… what is a delay for i2c? may be i want try to change it also…
-m@di
It’s better if we discuss in the Supported Forums. Please register and post your question there. I and others member may can respond for your questions.
Hi,
Great work.
but your 8 bit core deosnot support I2C bus than how deos it work as you are interfacing the DS1307 directly to port pins
It’s a very good question. I2C bus does unnecessarily require uC core modules support. I²C uses only two bidirectional open-drain lines, serial data (SDA) and serial clock (SCL), pulled up with resistors.
As you see in my code:
#define SDA P2_7 /* Set P2.7 = SDA */
#define SCL P2_6 /* Set P2.6 = SCL */
The Port 2 of P89V51RD2 are bidirectional open-drain ports. Therefore, I can interface I2C divices with my uC.
If you would like to know more about, see this.