Interfacing a DS1302 With an 8051-Type Microcontroller
Abstract
This application describes how to interface a DS1302 RTC using the 3-wire interface to an 8051-type microcontroller. The example includes a schematic and example software written in C.
DS1302 Pin Assignment
Description
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.
Operation
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 2. Schematic of DS1302 RTC.
For Larger Image