Qdatasheet_Logo
Integrated circuits, Transistor, Semiconductors Search and Datasheet PDF Download Site

HT49CA1 View Datasheet(PDF) - Holtek Semiconductor

Part Name
Description
MFG CO.
HT49CA1
Holtek
Holtek Semiconductor Holtek
'HT49CA1' PDF : 58 Pages View PDF
HT49RA1/HT49CA1
Configuring the Pulse Width Measurement Mode
In this mode, the width of external pulses applied to the
external timer pin can be measured. In the Pulse Width
Measurement Mode the timer clock source is supplied
by the internal clock. For the timer to operate in this
mode, the bit pair, T0M1/T0M0 or T1M1/T1M0, depend-
ing upon which timer is used, must both be set high. De-
pending upon which counter is used, if the T0E or T1Ebit
is low, once a high to low transition has been received
on the external timer pin, the timer will start counting un-
til the external timer pin returns to its original high level.
At this point the T0ON or T1ON bit, depending upon
which counter is used, will be automatically reset to zero
and the timer will stop counting. If the T0E or T1E bit is
high, the timer 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 returns to
its original low level. As before, the T0ON or T1ON, bit
will be automatically reset to zero and the timer will stop
counting. It is important to note that in the Pulse Width
Measurement Mode, the T0ON or T1ON bit is automati-
cally 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 T0ON or T1ON bit
can only be reset to zero under program control. The re-
sidual value in the timer, which can now be read by the
program, therefore represents the length of the pulse re-
ceived on the external timer pin. As the T0ON or T1ON
bit has now been reset, any further transitions on the ex-
ternal timer pin, will be ignored. Not until the T0ON or
T1ON 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 counter is con-
trolled by logical transitions on the external timer pin and
not by the logic level. As in the case of the other two
modes, when the counter is full, the timer will overflow
and generate an internal interrupt signal. The counter
will also be reset to the value already loaded into the
preload register. If the external timer pin is pin-shared
with other I/O pins, to ensure that the pin is configured to
operate as a pulse width measuring input pin, two things
have to happen. The first is to ensure that the
T0M1/T0M0 or T1M1/T1M0 bits place the Timer/Event
Counter in the pulse width measuring mode, the second
is to ensure that the port control register configures the
pin as an input. It should be noted that a timer overflow
and corresponding timer interrupt is one of the wake-up
sources. Note that the timer interrupts can be disabled
by ensuring that the ET0I or ET1I bits in the INTC0 or
INTC1 register are reset to zero.
I/O Interfacing
The Timer/Event Counter, when configured to run in the
event counter or pulse width measurement mode, re-
quire the use of the external pin for correct operation. As
this pin is a shared 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 en-
suring that the mode select bits in the Timer/Event
Counter control register, select either the event counter
or pulse width measurement mode. Additionally the Port
Control Register must be set high to ensure that the pin
is setup as an input. Any pull-high resistor on this pin 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 internal
system clock is used as the timer clock source and is
therefore synchronised with the overall operation of the
microcontroller. In this mode when the appropriate timer
register is full, the microcontroller will generate an inter-
nal interrupt signal directing the program flow to the re-
spective internal interrupt vector. For the pulse width
measurement mode, the internal system 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 syn-
chronized 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.
E x te rn a l T M R 0 /T M R 1
P in In p u t
T 0 O N /T 1 O N ( w ith T 0 E /T 1 E = 0 )
P r e s c a le r O u tp u t
In c re m e n t
T im e r C o u n te r
T im e r
+1
+2
+3
+4
P r e s c a le r O u tp u t is s a m p le d a t e v e r y fa llin g e d g e o f T 1 .
Pulse Width Measure Mode Timing Chart
Rev. 1.10
27
March 30, 2014
Share Link: GO URL

All Rights Reserved © qdatasheet.com  [ Privacy Policy ] [ Contact Us ]