16522 Versatile Interface Adapter (VIA) imer 1 Free-Run Mode he most important advantage associated with the latches in T1 the ability to produce a continuous series of evenly spaced terrupts and the ability to produce a square wave on PB7 whose equency is not affected by variations in the processor interrupt sponse time. This is accomplished in the “free-running™ mode. the free-running mode, the interrupt flag is set and the signal n PB7 is inverted each time the counter reaches zero at which me the timer automatically transfers the contents of the Jatch to the counter (16 bits) and continues to decrement from there. he interrupt flag can be cleared by writing TIC-H or TIL-H, by zading T1C-L, or by writing directly into the flag as described ter, However, it is not necessary to rewrite the timer to enable etting the interrupt flag on the next time-out. II interval timers in the R6522 are “re-trigqgerable”. Rewriting 16 counter witl always re-initialize the time-out period. In fact, the time-out can be prevented completely if the processor con- tinues to rewrite the timer before it reaches zero. Timer 1 will operate in this manner if the processor writes into the high order counter (T1C-H). However, by loading the latches only, the processor can access the timer during each down-counting oper- ation without affecting the time-out in process. instead, the data loaded into the latches will determine the length of the next time- out period. This capability is particularly valuable in the free- running mode with the output enabled. In this mode, the signal on P87 is inverted and the interrupt flag is set with each time- out. By responding to the interrupts with new data for the latches, the processor can determine the period of the next half cycle during each half cycle of the output signal on PB7. In this manner, very complex waveforms can be generated. A precaution to take in the use of PB7 as the timer output con- cers the Data Direction Register contents for PB7. Both DORB bit 7 and ACR bit 7 must be 1 for PB7 to function as the timer output. If one is 1 and other is 0, then P87 functions as a nor- mail outpin pin, controlled by ORB bit 7. . 2 LLP YP LI SL, LAL WRITE T1C-H | | | OPERATION j 7 ia i ‘ iG OUTPUT ae l j i as [ae PB7 OUTPUT j iy i " je Sens — N+ 4.5 cvctes —-|. N + 2 CYCLES | Figure 16. Timer 1 Free-Run Mode Timing Timer 2 Operation Timer 2 operates as an interval timer (in the “one-shot made snly), or as a counter for counting negative pulses on the PBE peripheral pin. A single contro! bit in the Auxiliary Control Register selects between these two modes. This timer is comprised of a “write-only” lower-order latch (T2L-L}, a “read-only” low-order pounter (T2C-L) and a read/write high order counter (T2C-H). The counter registers act as a 16-bit counter which decrements at $2 rate. Figure 17 illustrates the T2 Laich/Counter Registers. Timer 2 One-Shot Mode As an interval timer, T2 operates in the “one-shot” mode similar to Timer 1. In this mode, T2 provides a single interrupt for each “write T2C-H” operation. After timing out, the counter will con- ‘inue to decrement. However, setting of the interrupt flag is dis- zbted after initial time-out so that it will not be set by the counter decrementing again through zero. The processor must rewrite T2C-H to enable setting of the interrupt flag. The interrupt flag is cleared by reading T2C-L or by writing T2C-H. Timing for this operation is shown in Figure 18. Timer 2 Pulse Counting Mode in the pulse counting mode, T2 counts a predetermined num- ber of negative-going pulses on PB6. This is accomplished by first loading a number into T2. Writing into T2C-H clears the inter- rupt flag and allows the counter to decrement each time a pulse is applied to PBS. The interrupt flag is set when T2 counts down past zero. The counter will then continue to decrement with each pulse on PB6. However, it is necessary to rewrite T2C-H to allow the interrupt flag to set on a subsequent time-out. Timing for this mode is shown in Figure 19. The pulse must be low on the lead- ing edge of $2.