beautypg.com

Rtclk_init (), E 26) – Maxim Integrated 73S12xxF Software User Manual

Page 26

background image

73S12xxF Software User Guide

UG_12xxF_016

26

Rev. 1.50

4.2.4 Real Time Clock API - Available with the 68-pin 73S12xxF

The 73S12xxF provides a 32-bit counter selectable in 0.5, 1 or 2 second increments to measure time. This time
mark can also be used to generate RTC interrupts at 0.5, 1, 2, 4, or 8-second intervals. A 24-bit trimming
function, along with a 24-bit accumulator, is provided to correct the clock drift induced by the quartz crystal.
The device also supports a watchdog capability. This feature will give the processor 0.5 seconds to
respond to an RTC interrupt. If the RTC interrupt is not serviced within 0.5 seconds, a full RESET to the
72S12xxF is performed. To use the watchdog timer function, the RTC interrupt must be enabled.
Consequently, the watchdog will always be enabled when the RTC interrupt is enabled. It is not possible
to turn off the watchdog while the RTC interrupt is enabled.


Care should be taken as it is possible for the device to be put into an infinite reset loop when an
RTC interrupt is not serviced on time (within 0.5 second). When this problem occurs,
reprogram the Flash with a known good application/program using the TFP.


The RTC block uses the 32768 Hz oscillator signal or divider logic (from the 12 MHz oscillator circuit) to
produce 0.5 second time marks. The 32768 Hz oscillator can be disabled (see the

PowerOFF

API), but

is intended to operate at all times in all power consumption modes. If a 32 kHz crystal is not provided,
this oscillator must be disabled and the RTC will operate from an internal 96 MHz clock divided by 2930.
In this case, the RTC trim value should be set as described in the following paragraph.

The 3-byte accumulator can hold 2

24

= 16,777,216, which yields a 0.0596 PPM resolution. Using the 12 MHz

oscillator gives 96 MHz/2930 which will generate 32,764 Hz. The core RTC uses a 32,768 Hz Oscillator crystal.
This yields a 106 PPM error. Therefore, the trim value = (106 PPM) / (.0596 PPM) ~= 1778 (0x06F2).

When the accumulator reaches overflow, it will advance the counter one additional count if the trim value
is positive, or prevent the counter from advancing one count if the trim value is negative.

The trim value can be set in the API_12.h file.

RTClk_Init ()

must be called prior to using any of the RTC

APIs. Once the RTC is initialized, the 32 kHz OSC clock will always be running. To turn it off, use the

PowerOFF

(DISABLE_RTC) API.


The Real Time Clock API is described in detail below and includes:

RTClk_Init ()

(page 26)

RTCClk_Control ()

(page 27)

RTClk_Write ()

(page 27)

RTClk_Read (

) (page28)

RTCClk_GetTIME (

) (page 28)

RTCClk_SetTIME (

) (page 29)


RTClk_Init ()

Purpose

Initialize the Real Time Clock values by setting the accumulator to 0 and setting the
trim values as defined in api_12.h. The default base day is defined as 12:00:00,
01/01/2005 calculated using the Gregorian/Julian conversion defined in:

http://webexhibits.org/calendars/calendar-christian.html

.


When this function is called, the RTC is stopped and restarted. The RTC counter,
trim and accumulator will be loaded at the next 32 kHz clock positive edge. The RTC
interrupt is NOT set here. Use RTClk_Control() to set the interrupt. The RTC
counter continues to count whether the RTC interrupt is enabled or not.

The Interrupt service routine for the RTC interrupt can be masked using the Set_Event (eRTC,
pRTCVector) API. If customization of the RTC ISR is desirable, call Set_Event after this API is
called. See

Set_Event

() for its usage description.