ht82k70e-l Holtek Semiconductor Inc., ht82k70e-l Datasheet - Page 20

no-image

ht82k70e-l

Manufacturer Part Number
ht82k70e-l
Description
I/o Type 8-bit Otp Mcu
Manufacturer
Holtek Semiconductor Inc.
Datasheet
In this mode the internal clock, f
ternal clock for the 16-bit Timer/Event Counters. After
the other bits in the Timer Control Register have been
setup, the enable bit T0ON or T1ON, which is bit 4 of the
Timer Control Register, can be set high to enable the
Timer/Event Counter, however it will not actually start
counting until an active edge is received on the external
timer pin.
If the Active Edge Select bit T0E or T1E, which is bit 3 of
the Timer Control Register, is low, once a high to low
transition has been received on the external timer pin,
TMR0 or TMR1, the Timer/Event Counter will start
counting until the external timer pin returns to its original
high level. At this point the enable bit will be automati-
cally reset to zero and the Timer/Event Counter will stop
counting. If the Active Edge Select bit is high, the
Timer/Event Counter will begin counting once a low to
high transition has been received on the external timer
pin and stop counting when the external timer pin re-
turns to its original low level. As before, the enable bit
will be automatically reset to zero and the Timer/Event
Counter will stop counting. It is important to note that in
the Pulse Width Measurement Mode, the enable bit is
automatically reset to zero when the external control
signal on the external timer pin returns to its original
level, whereas in the other two modes the enable bit can
only be reset to zero under program control.
The residual value in the Timer/Event Counter, which
can now be read by the program, therefore represents
the length of the pulse received on the external timer
pin. As the enable bit has now been reset, any further
transitions on the external timer pin will be ignored. Not
until the enable bit is again set high by the program can
the timer begin further pulse width measurements. In
this way, single shot pulse measurements can be easily
made.
It should be noted that in this mode the Timer/Event
Counter is controlled by logical transitions on the external
timer pin and not by the logic level. When the Timer/Event
Counter is full and overflows, an interrupt signal is gener-
ated and the Timer/Event Counter will reload the value al-
ready loaded into the preload register and continue
counting. The interrupt can be disabled by ensuring that
the Timer/Event Counter Interrupt Enable bit in the Inter-
rupt Control Register, INTC0, is reset to zero.
Rev. 1.00
SYS
/4 is used as the in-
Pulse Width Measure Mode Timing Chart
20
I/O Interfacing
The Timer/Event Counter, when configured to run in the
event counter or pulse width measurement mode, re-
quires the use of an external pin for correct operation.
This is implemented by ensuring that the mode select bits
in the Timer/Event Counter control register, select either
the event counter or pulse width measurement mode.
Programming Considerations
When configured to run in the timer mode, an internal
timer clock source is used. In this mode, when the ap-
propriate timer register is full, the microcontroller will
generate an internal interrupt signal directing the pro-
gram flow to the respective internal interrupt vector. For
the pulse width measurement mode, the instruction
clock is also used as the timer clock source but the timer
will only run when the correct logic condition appears on
the external timer input pin. As this is an external event
and not synchronised with the internal timer clock, the
microcontroller will only see this external event when the
next timer clock pulse arrives. As a result there may be
small differences in measured values requiring pro-
grammers to take this into account during programming.
The same applies if the timer is configured to be in the
event counting mode which again is an external event
and not synchronised with the internal system or timer
clock.
When the Timer/Event Counter is read or if data is written
to the preload registers, the clock is inhibited to avoid er-
rors, however as this may result in a counting error, this
should be taken into account by the programmer. Care
must be taken to ensure that the timers are properly in-
itialised before using them for the first time. The associ-
ated timer interrupt enable bits in the interrupt control
register must be properly set otherwise the internal inter-
rupt associated with the timer will remain inactive. The
edge select, timer mode and clock source control bits in
timer control register must also be correctly set to ensure
the timer is properly configured for the required applica-
tion. It is also important to ensure that an initial value is
first loaded into the timer register before the timer is
switched on; this is because after power-on the initial
value of the timer register is unknown. After the timer has
been initialised the timer can be turned on and off by con-
trolling the enable bit in the timer control register. Note
HT82K70E-L/HT82K76E-L
September 15, 2009

Related parts for ht82k70e-l