DS1318 Pin Assignment
This application note demonstrates how to use the DS1318
Elapsed-Time Counter. The DS1318 has a 44-bit counter that increments once every 244µs. The 44-bit counter is accessed through six 8-bit registers (Figure 1
Figure 1. DS1318 44-bit counter configuration.
Conceptually, the 44-bit counter can be broken into a 12-bit sub-second counter and a 32-bit counter that increments once per second (Figure 2
). If sub-second resolution is not required, only the 32-bit second counter registers can be accessed.
Figure 2. The 12-bit sub-second and 32-bit second counters.
In the example for this application note, a software routine reads the 32-bit seconds counter continuously, and outputs the time and date in ASCII format through a UART on an 8051 microcontroller (µC) on each once-per-second change. The time and date value is based upon the elapsed time, in seconds, from January 1, 1970 00:00:00. A value of 00000000h would be January 1, 1970 00:00:00. A value of 42C924C0h corresponds to 2005/7/4 12:00:00.
Another routine configures the device's periodic interrupt to a 1Hz rate. Each time an interrupt occurs, an interrupt handling routine reads the counter data, converts the data to a time and date format, and outputs the data in ASCII through the UART.
Additional routines are possible. In other examples the DS1318 could: take user inputs to write data to a single register; take time and date information from the user and convert it to elapsed time in seconds from January 1, 1970; write the value to the counter. Another routine reads all the DS1318 registers and outputs them in hexadecimal format.
The hardware example in this application note places the DS1318 into the µC's data memory space. The µC accesses the DS1318's registers by reading and writing the appropriate data-memory locations.
A low-voltage 8051-compatible microcontroller, the DS80C323, is used in this example. User inputs and data outputs from the program are passed to the µC through an RS-232 interface from a terminal emulator program on a PC. More information about the DS80C323
microcontroller used in this application note can be found on our website.
The software is shown in the Program Listing, Figure 3
. A schematic of the circuit is shown in Figure 4
Figure 3. Program listing.
More Detailed Image
Figure 4. Circuit schematic.