HT82A520R HOLTEK [Holtek Semiconductor Inc], HT82A520R Datasheet - Page 20

no-image

HT82A520R

Manufacturer Part Number
HT82A520R
Description
Full Speed USB 8-Bit OTP MCU with SPI
Manufacturer
HOLTEK [Holtek Semiconductor Inc]
Datasheet
Configuring the Pulse Width Measurement Mode
In this mode, the Timer/Event Counter can be utilised to
measure the width of external pulses applied to the ex-
ternal timer pin. To operate in this mode, the Operating
Mode Select bit pair, TM1 or TM0, in the Timer Control
Register must be set to the correct value as shown.
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 TON, 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 TE , which is bit 3 of the
Timer Control Register, is low, once a high to low transi-
tion has been received on the external timer pin, TMR,
the Timer/Event Counter will start counting until the ex-
ternal timer pin returns to its original high level. At this
point the enable bit will be automatically 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 count-
ing when the external timer pin returns to its original low
level. As before, the enable bit will be automatically re-
set to zero and the Timer/Event Counter will stop count-
ing. It is important to note that in the Pulse Width
Measurement Mode, the enable bit is automatically re-
set to zero when the external control signal on the exter-
nal 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
Rev.1.00
Control Register Operating Mode
Select Bits for the Pulse Width Measure-
ment Mode
SYS
/4 is used as the in-
Pulse Width Measure Mode Timing Chart
Bit7 Bit6
1
1
20
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.
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, the instruc-
tion clock (system clock divided by 4) is used as the in-
ternal timer clock source for the two 16-bit timers and is
therefore synchronized with the overall operation of the
microcontroller. In this mode, when the appropriate
timer register is full, the microcontroller will generate an
internal interrupt signal directing the program 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 synchro-
nised 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 differ-
ences in measured values requiring programmers to
take this into account during programming. The same
applies if the timer is configured to be in the event count-
ing mode which again is an external event and not syn-
chronised with the internal system or timer clock.
HT82A520R/HT82A620R
October 23, 2009

Related parts for HT82A520R