Figure 1. DS3231 Pin assignment.
This application note demonstrates how to interface a DS3231 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 two general-purpose port pins on the microcontroller to operate as a master on the I²C bus. The DS3231 operates as a slave device on the same bus. The program demonstrates setting and reading the time and date, as well as reading and displaying temperature data. The program displays the time, date, and temperature information on an LCD display, which utilizes a standard HD44780 controller.
Pin assignment and a schematic of the DS3231 are shown in Figures 1
, respectively. The software is shown in Figure 3
For Larger Image
Figure 2. Schematic of the DS3231.
Download text fileFigure 3. Example Software