DS1302 Pin Assignment
This application note demonstrates how to interface a DS1302 real-time clock to an 8051-type microcontroller and provides example code showing basic interface routines. The microcontroller used in this example is the DS2250, and the software is written in C.
The program uses three general-purpose port pins on the microcontroller to control the 3-wire synchronous bus. The microcontroller initiates a data transfer by sending a command byte to the DS1302. The microcontroller then sends additional data and/or SCLKs to the DS1302, which transmits or receives data based upon the command byte.
The software is shown in Figure 1
. A schematic of the circuit is shown in Figure 2
Figure 1. Program Listing
(Download ZIP file)
For Larger Image
Figure 2. Schematic of DS1302 RTC.