
S3C7559/P7559
TIMERS and TIMER/COUNTERS
11-13
TC PROGRAMMABLE TIMER/COUNTER FUNCTION
Timer/counters can be programmed to generate interrupt requests at various intervals based on the selected
system clock frequency. Its 8-bit TC mode register TMODn is used to activate the timer/counter and to select the
clock frequency. The reference register TREFn stores the value for the number of clock pulses to be generated
between interrupt requests. The counter register, TCNTn, counts the incoming clock pulses, which are compared
to the TREFn value as TCNTn is incremented. When there is a match (TREFn = TCNTn), an interrupt request is
generated.
To program timer/counter to generate interrupt requests at specific intervals, choose one of four internal clock
frequencies (divisions of the system clock, fxx) and load a counter reference value into the reference register.
The count register is incremented each time an internal counter pulse is detected with the reference clock
frequency specified by TMODn.4–TMODn.6 settings. To generate an interrupt request, the TC interrupt request
flag (IRQTn) is set to logic one, the status of TOLn is inverted, and the interrupt is generated. The content of the
counter register is then cleared to 00H and TC continues counting. The interrupt request mechanism for TC
includes an interrupt enable flag (IETn) and an interrupt request flag (IRQTn).
TC OPERATION SEQUENCE
The general sequence of operations for using TC can be summarized as follows:
1.
Set TMODn.2 to "1" to enable TC0 and 1
2.
Set TMODn.6 to "1" to enable the system clock (fxx) input
3.
Set TMODn.5 and TMODn.4 bits to desired internal frequency (fxx/2n)
4.
Load a value to TREFn to specify the interval between interrupt requests
5.
Set the TC interrupt enable flag (IETn) to "1"
6.
Set TMODn.3 bit to "1" to clear TCNTn, IRQTn, and TOLn, and start counting
7.
TCNTn increments with each internal clock pulse
8.
When the comparator shows TCNTn = TREFn, the IRQTn flag is set to "1"
9.
Output latch (TOLn) logic toggles high or low
10. Interrupt request is generated
11. TCNTn is cleared to 00H and counting resumes
12. Programmable timer/counter operation continues until TMODn.2 is cleared to "0".