Software for the DS1307 Real Time Clock

The DS1307 Timekeeping Chip contains a real time clock/calendar and 56 bytes of static RAM. It communicates with a microprocessor via the I2C serial interface. The real time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with less than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator.

DS1307 mounted on EVBplus.  Click to download high res photo.
The photo above is of a DS1307 mounted in the application area of the MC68HC11 EVBplus Development board, from WYTEC. The software uses the LED display on the board to display as well as on the terminal.

The software uses a bit-bang method to implement the I2C protocol.  If you are not using the EVBplus board you can remove the equate line at the start of the source file and reassemble.  This will remove the LED interface routine.  The include file should be useable with most MC68HC11's and MC68HC12's.

Click here to get HC11 software for the DS1307

I have found that the Inter-Integrated Circuit Module is rather difficult to understand but after considerable debugging I managed to get it working reliably.  I have a DS1307 on my MC9S08SH8 Project Board and MC9S08SV16 Project Baord.

Click here to get 9S08 software for the DS1307

Freescale has an application note AN1759 that describes the chip and its use with the MC68HC705J1A with software.

Sparkfun has a small module with a DS1307.  So does Futurlec and RobotShop or this and Adafruit and DFRobot and Maker Shed and GarageLab and or this

See also my Software for the DS1302 page

Roger's Embedded Microcontrollers Home Page

This page written by Roger Schaefer. Last updated December 12, 2013