
III PERIPHERAL BLOCK: CLOCK TIMER
Examples of Use of Clock Timer
The following shows examples of use of the clock timer and how to control the timer in each case.
To use the clock timer as a timer/counter
Example in which while the CPU is inactive, the clock timer is kept operating in order to start again the CPU after a specified length of time has elapsed (e.g., three days):
1.Make sure the
Wait for approximately three seconds after the oscillation starts for its oscillation to stabilize.
2.Disable the clock timer interrupt using the interrupt controller (ECTM = "0").
3.Stop the clock timer and set "3 days" in the
4.Choose a
5.Reset the interrupt factor and alarm factor generation flags (FCTM = "0", TCAF = "0").
6.Reenable the clock timer interrupt using the interrupt controller (ECTM = "1").
7.Switch the CPU operating clock to the
8.Turn off the
9.Reset the clock timer (TCRST = "0").
10.Start the clock timer (TCRUN = "1").
11.Execute the halt instruction to stop the CPU.
:
Wait until an interrupt is generated by a
:
12.If necessary, turn on the
In the above example, if the device is reset before a
•The CPU starts up using the OSC3 clock.
•The clock timer counters are not reset. They remain in the RUN state.
The time during which the CPU has been idle can be checked by reading out the clock timer counters.
For using the clock timer as RTC
Example in which the clock timer is kept operating and an alarm is generated at 10:00 A.M. every day:
1.Disable the clock timer interrupt using the interrupt controller (ECTM = "0").
2.Stop the clock timer (TCRUN = "0").
3.Reset the clock timer (TCRST = "1").
4.Set the current day and time in the minute (TCHD), hour (TCDD), and day (TCND) counters. For the day counter, set a number of days starting from the reference day (e.g., January 1, 1990). When the count is read, it is converted into the current date by the software.
5.Set "10:00" in the
6.Select an a
7.Reset the interrupt factor and
8.Reenable the clock timer interrupt using the interrupt controller (ECTM = "1").
9.Start the clock timer (TCRUN = "1").
:
The clock timer is made to generate an interrupt at 10:00 every day by an
:
In the above example, if any interrupt factor other than an alarm is selected, an interrupt is also generated by that interrupt factor. To determine which factor caused the interrupt generated, read the interrupt factor generation flag TCIF and alarm factor generation flag TCAF. If TCAF is set to 1, the interrupt has been caused by an alarm. If you select an interrupt factor (other than a
EPSON | S1C33210 FUNCTION PART |