English
Language : 

DS80C320-MCG Datasheet, PDF (159/175 Pages) Dallas Semiconductor – High-Speed Microcontroller User Guide
High-Speed Microcontroller User’s Guide
Although it may be desired to program the RTC time registers and then start the oscillator, this sequence
is not recommended because of the delay incurred by the RTC crystal warm-up period.
There are two situations where the RTC will be started. The first is the case where the RTC has been
intentionally halted following normal operation. When the RTCE bit is set, the time registers will
continue their count from the last setting when the clock was stopped. The RTC time value will be
inaccurate, although the settings of the RTC alarm registers and the RTCC register will remain intact.
The second case is following the application of battery power. Most of the registers associated with the
RTC are non-volatile, so that they will maintain their state while VCC is removed. When battery power is
applied to the device, however, the battery backed registers and bits associated with the RTC will be in an
indeterminate state and will need to be reinitialized. This includes the RTC Interrupt Flag, RTCIF
(RTCC.1), which should be cleared before setting the RTC Interrupt Enable bit (EIE.5).
The RTC can be halted by clearing the RTCE bit to 0. This will immediately halt the RTC and will
freeze all the time registers at their current value and preserve all the RTC settings. If RTC functions are
not desired, this can be used to reduce the power consumption of the device while in battery backed
mode.
SETTING AND READING THE RTC TIME REGISTERS
Access to the RTC time registers (RTCSS, RTCS, RTCM, RTCH, RTCD0, RTCD1) is enabled by the
RTCRE (RTCC.3) and RTCWE (RTCC.2) bits. Both user software and the internal clock directly write
and read the RTC time. To prevent the possibility of both user software and the internal timer accessing
the same register simultaneously, the DS87C530 incorporates a register locking mechanism. Updates to
the RTC time registers by the internal timer are temporarily suspended for up to 1.95 ms during software
read or write operations. If a subsecond timer tick should occur during the 1.95 ms window, it will be
processed immediately as soon as either the RTCWE or RTCRE bit is cleared. Because the subsecond
timer tick interval is 3.906 ms, the 1.95 ms window allows sufficient time to complete any operations and
process suspended timer ticks before the next timer tick occurs. In this way, no timer ticks can be lost,
and accessing the time registers will not affect the accuracy of the RTC. To allow any pending timer
ticks to propagate through the RTC circuitry, software must wait 4 machine cycles after setting the
RTCWE or RTCRE bits before accessing any of the RTC time registers. The first timer tick following
the clearing of the RTWCE bit will be approximately 1.95 ms. All following timer ticks will be 3.90625
ms.
Reading the current time from any or all of the RTC time registers is accomplished by the following
procedure:
1. Disable all interrupts by clearing the EA bit (IE.7),
2. Set the RTCRE bit (RTCC.3),
3. Wait 4 machine cycles,
4. Read the appropriate register(s) within 1 ms of RTCRE being set,
5. Clear the RTCRE bit (RTCC.3),
6. Enable interrupts by setting the EA bit (IE.7).
The time on the DS87C530 is set by writing to the Clock Registers. The Second, Minute, Hour, Day of
the Week, and Day Count can be set by writing to the respective registers. It is not possible to set the
Subsecond Real Time Clock Register (RTCS; FAh). This register is automatically reset to 00h when the
RTCWE bit is cleared, either through software or the automatic time-out of the 1.95 ms write window.
159 of 175