ht82a836r Holtek Semiconductor Inc., ht82a836r Datasheet - Page 22

no-image

ht82a836r

Manufacturer Part Number
ht82a836r
Description
Usb Audio Mcu
Manufacturer
Holtek Semiconductor Inc.
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
HT82A836R
Manufacturer:
HOLTEK/合泰
Quantity:
20 000
enable bit is automatically reset to zero when the exter-
nal control signal on the external timer pin returns to its
original level, whereas in the other two modes the en-
able 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 exter-
nal timer pin and not by the logic level. When the
Timer/Event Counter is full and overflows, an interrupt
signal is generated and the Timer/Event Counter will re-
load the value already 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 Interrupt Control Register, INTC0, is reset to
zero.
As the external timer pin is shared with an I/O pin, to en-
sure that the pin is configured to operate as a pulse
width measurement pin, two things have to happen. The
first is to ensure that the Operating Mode Select bits in
the Timer Control Register place the Timer/Event Coun-
ter in the Pulse Width Measurement Mode, the second
is to ensure that the port control register configures the
pin as an input.
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.
As the external timer pin is pin-shared with an I/O pin, it
must be configured correctly to ensure it is setup for use
as a Timer/Event Counter input and not as a normal I/O
pin. This is implemented by ensuring that the mode se-
lect bits in the Timer/Event Counter control register, se-
lect either the event counter or pulse width
measurement mode. Additionally the Port Control Reg-
ister bit for this pin must be set high to ensure that the
Rev. 1.00
Pulse Width Measure Mode Timing Chart
22
pin is setup as an input. Any pull-high configuration for
this pins will remain valid even if the pin is used as a
Timer/Event Counter input.
Programming Considerations
When configured to run in the timer mode, the f
used as the timer clock source and is therefore synchro-
nised 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 in-
terrupt vector. For the pulse width measurement mode,
the f
but the timer will only run when the correct logic condi-
tion appears on the external timer input pin. As this is an
external event and not synchronized with the internal
timer clock, the microcontroller will only see this external
event when the next timer clock pulse arrives. As a re-
sult there may be small differences in measured values
requiring programmers to take this into account during
programming. The same applies if the timer is config-
ured to be in the event counting mode which again is an
external event and not synchronised with the f
clock.
When the Timer/Event Counter is read or if data is writ-
ten to the preload registers, the clock is inhibited to
avoid errors, however as this may result in a counting er-
ror, this should be taken into account by the program-
mer. Care must be taken to ensure that the timers are
properly initialised before using them for the first time.
The associated timer enable bits in the interrupt control
register must be properly set otherwise the internal in-
terrupt 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
application. 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 controlling the enable bit in the timer control regis-
ter. Note that setting the timer enable bit high to turn the
timer on, should only be executed after the timer mode
SYS
/4 clock is also used as the timer clock source
HT82A836R
March 20, 2008
SYS
SYS
/4 is
/4

Related parts for ht82a836r