UPI-41A/41AH/42/42AH USER’S MANUAL
STOP TCNT
Stop Timer/Event Counter
Opcode:
0 1 1 0
0 1 0 1
This instruction is used to stop both time accumulation and event counting.
Example:
Disable interrupt, but jump to interrupt routine after eight overflows and stop timer. Count
overflows in register 7.
START: DIS TCNTI
;DISABLE TIMER INTERRUPT
CLR A
;CLEAR ACC TO ZERO
MOV T,A
;MOV ZERO TO TIMER
MOV R7,A
;MOVE ZERO TO REG 7
STRT T
;START TIMER
MAIN:
JTF COUNT
;JUMP TO ROUTINE ‘COUNT’
;IF TF
e
1 AND CLEAR TIMER FLAG
JMP MAIN
;CLOSE LOOP
COUNT: INC R7
;INCREMENT REG 7
MOV A,R7
;MOVE REG 7 CONTENTS TO ACC
JB3 INT
;JUMP TO ROUTINE ‘INT’ IF ACC
;BIT 3 IS SET (REG 7
e
8)
JMP MAIN
;OTHERWISE RETURN TO ROUTINE
;MAIN
.
.
.
INT: STOP TCNT
;STOP TIMER
JMP 7H
;JUMP TO LOCATION 7 (TIMER
;INTERRUPT ROUTINE)
STRT CNT
Start Event Counter
Opcode:
0 1 0 0
0 1 0 1
The TEST 1 (T
1
) pin is enabled as the event-counter input and the counter is started. The
event-counter register is incremented with each high to low transition on the T
1
pin.
Example:
Initialize and start event counter. Assume overflow is desired with first T
1
input.
STARTC: EN TCNTI
;ENABLE COUNTER INTERRUPT
MOV A,
Ý
OFFH
;MOVE ‘FF’ HEX (ONES) TO
;ACC
MOV T,A
;MOVE ONES TO COUNTER
STRT CNT
;INPUT AND START
STRT T
Start Timer
Opcode:
0 1 0 1
0 1 0 1
Timer accumulation is initiated in the timer register. The register is incremented every 32
instruction cycles. The prescaler which counts the 32 cycles is cleared but the timer register is
not.
Example:
Initialize and start timer.
STARTT: EN TCNTI
;ENABLE TIMER INTERRUPT
CLR A
:CLEAR ACC TO ZEROS
MOV T,A
;MOVE ZEROS TO TIMER
STRT T
;START TIMER
50