Pin Assignment
Description
The DS1602 and DS1603 from Dallas Semiconductor offer a simplified hardware solution for keeping time as well as tracking powered up time of a system. The DS1602 and DS1603 can be read and written directly by a microprocessor or microcontroller using simple software; however, a more creative software algorithm can be used to track years, months, days, day of week, time of day, etc. In addition, power-up time and number of power-up cycles can also be tracked using the DS1602/DS1603 with appropriate software.The continuous counter and power-on counter in the DS1602/DS1603 are 32-bit counters which count in seconds and can be read and written through the DS1602/DS1603 3-wire serial interface. For the most basic implementation:
- The continuous counter will be set once and left to increment until it reaches its maximum value;
- The powered up counter will be initially cleared once, and left to increment until it reaches its maximum value.
For a system that needs 100+ years of continuous timekeeping ability, the entire 32-bit counters may be required; but for users where the maximum continuous counter time required could be about 5 years, the unused counter bits space can be put to better use as memory bits for storing power-up cycling information.
As seen in Figure 1, DS1602/DS1603 can be partitioned to provide a continuous time counter and a power-up time counter with the capability to count up to 4.75 years, leaving the remaining higher bits of the counter available as a read/write nonvolatile memory.
The software implementation requires the use of three registers, so a third register must be mapped into the available two as in Figure 1.
An example of how the counters may be used to accomplish this task follows.
Figure 1. Mapping three registers onto two.
Continuous Counter Map
Bits 1-24: Remain as continuous time base measurement, up to 16.7 x 106 seconds or 0.53 years.Bit 25: Buffer or overflow bit; for when the continuous time counter reaches its maximum value and has not been read and reset by the processor. This bit also serves to separate the counter part of the register from the part which will be used as memory bits.
Bits 26-28: Number of years continuous time has been running x 0.53.
Bits 29-32: Number of power cycles x 128. These four bits serve as a register which is incremented once for each full count reached in bits 26-32 of the power-up counter.
Powered Up Counter Map
Bits 1-24: Remain as nonvolatile seconds measurement of powered up seconds, storing up to 16.7 x 106 seconds, or 0.53 years.Bit 25: Buffer or overflow bit; for when the power-up counter reaches its maximum value and has not been read and reset by the processor. This bit also serves to separate the counter part of the register from the part which will be used as memory bits.
Bits 26-32: The high 7 bits of the power-up counter are the 1-127 count storage area for the number of power-up cycles the DS1602 or DS1603 has seen.
With this discipline and the proper software algorithms in place, power-on time and continuous time are maintained by the DS1602/DS1603's self-contained counters while the number of power-up cycles and years of elapsed time x 0.53 is maintained in the higher order bits of the counters which are used as memory.
This implementation requires that a microcontroller must be prepared to read/write the DS1602 or DS1603 at least once every year.
For Continuous Time Tracking
When the lower 24 bits of the continuous counter have exceeded 0.53 years and set bit 25 to 1, the controller must read the continuous counter, determine the status of bit 25, and if 1, clear the bit and increment the value in bits 26-28 by one half-year. If bit 25 is not set, the lower 24 bits of the register have yet to reach 0.53 years and can continue counting.Once the value in bits 26-28 has reached 111, or 7 x 0.53 years, the continuous time counter can continue to count up to 1.06 years in the lower 24 bits plus the overflow of 0.53 in bit 25 for a maximum value of 9 x 0.53 years.
Figure 2. For continuous time tracking.
For Power-up Time Tracking
When the lower 24 bits of the power-up counter have exceeded 0.53 years and set bit 25 of the counter to 1, the controller must read the power-up counter, determine the status of bit 25, and if 1, clear the bit and store the value in external memory so that the power-up counter can continue to count. The maximum power-up time that can be stored in this way is 2 x 0.53 years within the DS1602/DS1603.Figure 3. For power-up time tracking.
For Number of Power-up Cycles Tracking
Performing this function with the DS1603 or DS1602 is primarily a software task. When originally written with a start value or cleared, bits 25-32 of the power-up counter must be set to 0. Upon each power-up thereafter, the controller or processor connected to the DS1603 must read the power-up counter and examine the value stored in the high 7 bits. If the value is less than 1111111, then the controller must increment the value and write it back to the 7 higher order bits. If the value in the higher order bits is 1111111, the controller must set the value of 0000000, read the value in the high 4 bits of the continuous time counter, increment it by 1, and write the new value back to the high 4 bits. Using this software algorithm, the DS1603 or DS1602 can be used to record and store up to 2,047 power cycles.Figure 4. For number of power-up cycles tracking.
評論
查看更多