DS1302 Timekeeping Chip

The DS1302 is a cheap, simple to use timekeeping IC (RTC). Aditionally its 31-bytes of battery-backed SRAM can be used to store settings.

Hello World

Import programDS1302_HelloWorld

DS1302 Hello World program

Library

Import libraryDS1302

Library to make use of the DS1302 timekeeping IC. The functions are identical to those used by the mbed RTC's

Pinout

Datasheet

http://datasheets.maximintegrated.com/en/ds/DS1302.pdf

Notes

You can use the DS1302 for mbed boards with no RTC, or boards like the KL25Z which do have an RTC, but no proper battery connection to keep it running when the board is unpowered. The DS1302 also contains 31-bytes of RAM which remain valid as long as there is battery power. The IC supports trickle charging of a battery, but the library does not implement this, and neither do the standard available breakout boards: since it should run virtually forever on a CR2032 this is generally not a problem.

The DS1302 is easy to add to your project, there are breakout boards available, but a coin cell holder and a 32kHz crystal are all you need to connect it besides the DS1302 (DIP available) itself. There are better ICs, with integrated crystals, but the DS1302 is cheap :).

The library for this component calculates the internally used BCD fields to a UNIX time stamp, which the standard C functions and the mbed lib also use. If you prefer to directly use the values stored in the IC (which will be a bit faster), there is the following library, however some functions are lacking or not properly implemented:

Import libraryds1302

Real Time Clock ds1302 library


You need to log in to post a discussion