233
Timer and Counter Instructions
Section 5-16
If IR or LR bits are used for control bits, their status will be lost during any
power interruption. If it is necessary to maintain status to resume execution at
the same step, HR bits must be used.
Flags
25407:
Step Start Flag; turns ON for one cycle when STEP(08) is executed
and can be used to reset counters in steps as shown below if neces-
sary.
5-16 Timer and Counter Instructions
TIM and TIMH(15) are decrementing ON-delay timer instructions which
require a TIM/CNT number and a set value (SV). STIM(69) is used to control
the interval timers, which are used to activate interrupt routines.
CNT is a decrementing counter instruction and CNTR(12) is a reversible
counter instruction. Both require a TIM/CNT number and a SV. Both are also
connected to multiple instruction lines which serve as an input signal(s) and a
reset. CTBL(63), INT(89), and PRV(62) are used to manage the high-speed
counter. INT(89) is also used to stop pulse output.
Any one TIM/CNT number cannot be defined twice, i.e., once it has been
used as the definer in any of the timer or counter instructions, it cannot be
used again. Once defined, TIM/CNT numbers can be used as many times as
required as operands in instructions other than timer and counter instructions.
TIM/CNT numbers run from 000 through 511. No prefix is required when
using a TIM/CNT number as a definer in a timer or counter instruction. Once
defined as a timer, a TIM/CNT number can be prefixed with TIM for use as an
operand in certain instructions. The TIM prefix is used regardless of the timer
instruction that was used to define the timer. Once defined as a counter, a
TIM/CNT number can be prefixed with CNT for use as an operand in certain
instructions. The CNT is also used regardless of the counter instruction that
was used to define the counter.
TIM/CNT numbers can be designated as operands that require either bit or
word data. When designated as an operand that requires bit data, the TIM/
CNT number accesses a bit that functions as a `Completion Flag’ that indi-
cates when the time/count has expired, i.e., the bit, which is normally OFF, will
turn ON when the designated SV has expired. When designated as an oper-
and that requires word data, the TIM/CNT number accesses a memory loca-
tion that holds the present value (PV) of the timer or counter. The PV of a
timer or counter can thus be used as an operand in CMP(20), or any other
SNXT(09) 01000
CP
R
CNT 01
#0003
00000
00100
25407
STEP(08) 01000
1 cycle
25407
01000
Start
Address Instruction
Operands
Address Instruction
Operands
00000 LD
00000
00001 SNXT(09)
01000
00002 STEP(08)
01000
00003 LD
00100
00004 LD
25407
00005 CNT
01
# 0003