Line 6: Line 6:
 
The Real time clock DS1307 IC basically is stand alone time clock with following features.
 
The Real time clock DS1307 IC basically is stand alone time clock with following features.
 
*Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation valid up to 2100.
 
*Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation valid up to 2100.
 +
*The clock operates in either the 24-hour or 12-hour format with AM/PM indicator.
 
*56-byte, battery-backed, nonvolatile (NV) RAM for data storage
 
*56-byte, battery-backed, nonvolatile (NV) RAM for data storage
 
*Two-wire(I2C) serial interface
 
*Two-wire(I2C) serial interface
Line 12: Line 13:
 
*Consumes less than 500nA in battery backup mode with oscillator running
 
*Consumes less than 500nA in battery backup mode with oscillator running
 
*Optional industrial temperature range: -40°C to +85°C
 
*Optional industrial temperature range: -40°C to +85°C
 +
 +
==DS1307 Pins==
 +
Below image shows the pin diagram and the recommended connections for DS1307.
 +
[[FILE:DS1307_PinDiagram.png]]
 +
<b>VCC, GND:</b> These pins are used to provide the power to the chip. When 5V is applied within normal limits, the device is fully accessible and data can be written and read. When a 3V battery is connected to the device and VCC is below 1.25 x VBAT, reads and writes are inhibited. However, the timekeeping function continues unaffected by the lower input voltage. As VCC falls below VBAT the RAM and timekeeper are switched over to the external power supply (nominal 3.0V DC) at VBAT.<br>
 +
 +
<b>X1-X2:</b>Pins to connect the external 32.768kHz oscillator that provides the clock source to the chip.<br>
 +
 +
<b>Vbat:</b> A 3.3v Lithium battery can be connected to thi pin in order to provide the power source when the external supply voltage is not available. Battery voltage must be held between 2.0V and 3.5V for proper operation.<br>
 +
 +
<b>SCL:</b> This pin must be connected to SCL pin of the I2C Bus/Master.<br>
 +
 +
<b>SDA:</b> This pin must be connected to SDA pin of the I2C Bus/Master.<br>
 +
 +
<b>SQW/OUT:</b> When enabled, the SQWE bit set to 1, the SQW/OUT pin
 +
outputs one of four square wave frequencies (1Hz, 4kHz, 8kHz, 32kHz).
 +
 +
*<b>Note:</b> The SCL,SDA and SQW are open drain and must be pulled up with appropriate pull up resistors as shown in the image.
 +
 +
==DS1307 Memory==

Revision as of 22:30, 17 May 2016

In this tutorial we will see hot to interface DS1307(RTC) with Pic16f877a.
First we will see the internals of DS1307 and later how to read and write the date and time.

DS1307 Basics

The Real time clock DS1307 IC basically is stand alone time clock with following features.

  • Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation valid up to 2100.
  • The clock operates in either the 24-hour or 12-hour format with AM/PM indicator.
  • 56-byte, battery-backed, nonvolatile (NV) RAM for data storage
  • Two-wire(I2C) serial interface
  • Programmable squarewave output signal
  • Automatic power-fail detect and switch circuitry
  • Consumes less than 500nA in battery backup mode with oscillator running
  • Optional industrial temperature range: -40°C to +85°C

DS1307 Pins

Below image shows the pin diagram and the recommended connections for DS1307. DS1307 PinDiagram.png VCC, GND: These pins are used to provide the power to the chip. When 5V is applied within normal limits, the device is fully accessible and data can be written and read. When a 3V battery is connected to the device and VCC is below 1.25 x VBAT, reads and writes are inhibited. However, the timekeeping function continues unaffected by the lower input voltage. As VCC falls below VBAT the RAM and timekeeper are switched over to the external power supply (nominal 3.0V DC) at VBAT.

X1-X2:Pins to connect the external 32.768kHz oscillator that provides the clock source to the chip.

Vbat: A 3.3v Lithium battery can be connected to thi pin in order to provide the power source when the external supply voltage is not available. Battery voltage must be held between 2.0V and 3.5V for proper operation.

SCL: This pin must be connected to SCL pin of the I2C Bus/Master.

SDA: This pin must be connected to SDA pin of the I2C Bus/Master.

SQW/OUT: When enabled, the SQWE bit set to 1, the SQW/OUT pin outputs one of four square wave frequencies (1Hz, 4kHz, 8kHz, 32kHz).

  • Note: The SCL,SDA and SQW are open drain and must be pulled up with appropriate pull up resistors as shown in the image.

DS1307 Memory