
Semiconductor Group
86
On-Chip Peripheral Components
Event Counter Mode
In the counter function, the timer 2 is incremented in response to a 1-to-0 transition at its
corresponding external input pin T2 (P1.7). In this function, the external input is sampled every
machine cycle. When the sampled inputs show a high in one cycle and a low in the next cycle, the
count is incremented. The new count value appears in the timer register in the cycle following the
one in which the transition was detected. Since it takes two machine cycles (24 oscillator periods)
to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. There
are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is
sampled at least once before it changes, it must be held for at least one full machine cycle (see also
section 7.1 "Parallel I/O" for the exact sample time at the port pin P1.7).
Note:
The prescaler must be off for proper counter operation of timer 2, i.e. T2PS must be 0.
In either case, no matter whether timer 2 is configured as timer, event counter, or gated timer, a
rolling-over of the count from all 1’s to all 0’s sets the timer overflow flag TF2 (bit 6 in SFR IRCON,
interrupt request control) which can generate an interrupt.
lf TF2 is used to generate a timer overflow interrupt, the request flag must be cleared by the interrupt
service routine as it could be necessary to check whether it was the TF2 flag or the external reload
request flag EXF2 which requested the interrupt (for EXF2 see below). Both request flags cause the
program to branch to the same vector address.
The input clock to timer 2 is selected by bits T2I0, T2I1, and T2PS as listed in figure 7-35.
Reload of Timer 2 (see figure 7-33 b) )
The reload mode for timer 2 is selected by bits T2R0 and T2R1 in SFR T2CON as listed in
figure 7-35. Two reload modes are selectable:
In mode 0, when timer 2 rolls over from all 1’s to all 0’s, it not only sets TF2 but also causes the
timer 2 registers to be loaded with the 16-bit value in the CRC register, which is preset by software.
The reload will happen in the same machine cycle in which TF2 is set, thus overwriting the count
value 0000H.
In mode 1, a 16-bit reload from the CRC register is caused by a negative transition at the
corresponding input pin T2EX/P1.5. In addition, this transition will set flag EXF2, if bit EXEN2 in
SFR IEN1 is set. lf the timer 2 interrupt is enabled, setting EXF2 will generate an interrupt (more
about interrupts in section 8). The external input pin T2EX is sampled in every machine cycle. When
the sampling shows a high in one cycle and a low in the next cycle, a transition will be recognized.
The reload of timer 2 registers will then take place in the cycle following the one in which the
transition was detected.
*
Summary of Contents for SAB 80515 Series
Page 9: ...Semiconductor Group 9 Introduction Figure 1 2 Block Diagram ...
Page 12: ...Semiconductor Group 12 Fundamental Structure Figure 2 1 Detailed Block Diagram ...
Page 18: ...Semiconductor Group 18 Central Processing Unit Figure 3 1 Fetch Execute Sequence ...
Page 73: ...Semiconductor Group 73 On Chip Peripheral Components Figure 7 25 A D Converter Block Diagram ...
Page 83: ...Semiconductor Group 83 On Chip Peripheral Components Figure 7 33 a Timer 2 Block Diagram ...
Page 215: ...Device Specifications Semiconductor Group 215 ...
Page 217: ...Device Specifications Semiconductor Group 217 Pin Configuration P LCC 68 ...
Page 219: ...Device Specifications Semiconductor Group 219 Logic Symbol ...
Page 226: ...Device Specifications Semiconductor Group 226 Figure 1 Block Diagram ...
Page 229: ...Device Specifications Semiconductor Group 229 Figure 2 Memory Address Spaces ...
Page 239: ...Device Specifications Semiconductor Group 239 Figure 4 Block Diagram of the A D Converter ...
Page 241: ...Device Specifications Semiconductor Group 241 Figure 5 Interrupt Request Sources ...
Page 242: ...Device Specifications Semiconductor Group 242 Figure 6 Interrupt Priority Level Structure ...