R6522 Versatile Interface Adapter (VIA) COUNTER/TIMERS There are two independent 16-bit counter/timers (called Timer 1 and Timer 2) in the R6522. Each timer is controlled by writing bits into the Auxiliary Control Register (ACR) to select the mode of operation (Figure 14). Timer 1 Operation Interval Timer T1 consists of two 8-bit latches (Figure 12) and a 16-bit counter (Figure 13). The latches store data which is to be loaded into the counter. After loading, the counter decrements at @2 clock rate. Upon reaching zero, an interrupt flag is set, and IRQ goes low if the T1 interrupt is enabled. Timer 1 then disables any further interrupts and automatically transfers the contents of the latches into the counter and continues to decre- ment. {n addition, the timer may be programmed to invert the output signal on peripheral pin PB7 each time it '‘times-out"’. Each af these modes is discussed separately below. Note that the processor does not write directly into the low-order counter (T1C-L). Instead, this half of the counter is loaded automatically from the fow order latch (TIL-L) when the processor writes into the high order counter (11C-H). In fact, it may not be necessary to write to the tow order counter in some applications since the timing operation is triggered by writing to the high order latch. REG 6—TIMER 1 LOW-ORDER LATCH FL GUST se sr] 2prgo 3 4 COUNT be 16 | | VALUE 128 = WRITE - B SITS LOADED INTO T+ LOW-CADER LATCHES THIS OPERATION [5 NO DIFFERENT THAN A WAITE INTO REG 4 READ - 8 BITS FROM T1 LOW-ORDER LATCHES TRANSFERRED TO MPU. UNLIKE REG 4 OPERATION, THIS DOES NOT CAUSE RESET OF 71 INTERRUPT FLAG REG 7—TIMER 1 HIGH-ORDER LATCH rheJalataiotils bron 512 toga ———---=--wenwe 2048 | COUNT 4096 | VALUE BI92 16384 32768} WRITE ~ 6 BITS LOADED INTO T? HIGH-ORDER LATCHES. UNLIKE REG 4 OPERATION NOQ LATCH-TO-COUNTEA TRANSFERS TAKE PLACE READ 8 ITS FROM Tt HIGH-ORNER LATCHES TRANGFERRED TO MPY. Figure 12. Timer 1 (T1} Latch Registers REG 4—TIMER 1 LOW-ORDER COUNTER 716 SOE Zz}: ]0 Lat 2 4a | COUNT 16 | VALUE 32 a 123) WRITE - 8 BITS LOADED INTO T1 LOW-OROER LATCHES LATCH CONTENTS ARE TRANSFERRED INTO LOW. QROER COUNTER AT THE TIME THE HI ORDER COUNTER 1S LOADED ne & Sy. READ ~ 6 BITS FROM T1 LOW-ORDER COUNTER TRANSFERRED 7O MPU IN ADDITION. T1 INTERAUPT FLAG iS BESET (BIT 6 (N INTERRUPT FLAG REGISTER) REG 5-—-TIMER 1 HIGH-ORDER COUNTER TIE FS PA PAP Vp rp 9 Le 4 bard 1024 zag | COUNT aovg | VALUE B192 16384) 32768) WRITE - 6 AITS LODGED INTO T1 HIGH-ORDER LATCHES. ALSO. AT THIS TIME BOTH HIGH. AND LOW-ORDER LATCHES TRANSFERRED INTO T1 COUNTER. Tr INTERRUPT FLAG ALSO IS RESET READ - 8 BTS FROM T1 HIGH-ORDER COUNTER TRANSFERRED TO MPU Figure 13. Timer 1 (T1) Counter Registers