Close

DS1302 - How We Keep Time

A project log for MCU-Less DS1302 Calendar Clock

Doing SPI with a microcontroller is boring. Why not do it with dozens of logic chips and 555 instead?

sleepy-ponySleepy Pony 01/03/2022 at 16:170 Comments

What is an RTC?

The heart of this clock is a battery-backed RTC chip. Real-Time Clock (RTC) is a type of interface chip that is responsible for the timekeeping of the system. An RTC with a battery-backed feature means the chip has a separate power source for the chip to keep the time when the main power fails, which means I don't have to set the time again every time I unplug it.


DS1302 Trickle-Charge Timekeeping Chip

There are many choices of RTC chips available on the market today, I have decided to use DS1302 for many reasons:

Datasheet is here: https://datasheets.maximintegrated.com/en/ds/DS1302.pdf


How should we make it tick?

DS1302 Block Diagram
DS1302 Block Diagram (from datasheet)

First is the block diagram. We can see that we need to:

So now we have this circuit below:

Note: I do include 100nF decoupling capacitors at every Vcc pin on every chip, but I put these all in the power input sheet, so they will not show on the pictures.

DS1302 Circuit
DS1302 Circuit

Communications

DS1302 SPI Communication
DS1302 SPI Communication (from datasheet)
DS1302 Commands List
DS1302 Commands List (from datasheet)

Communications with the chip use a common SPI protocol. First, we drive the chip enable (CE) high, then we feed our clock signal in the SCLK pin, and read/write the data on the I/O pin. However, from the datasheet there are some important points:

From what we gathered from the datasheet, to build an MCU-Less clock based on this chip we would need to have the following:

You can see there's quite a lot to do, which I will write about them in the next log.

Thanks for reading! :D

Discussions