Chapter 1 Hardware Structure
Configuring the Event Counter Mode
In this mode, a number of externally changing logic events, occurring on the external timer pin, can
be recorded by the internal timer. For the timer to operate in the event counting mode, the bit pair,
TM1/TM0, T0M1/T0M0, T1M1/T1M0 or T2M1/T2M0, depending upon which timer is used, must
be set to
²0²
and
²1²
respectively. The timer-on bit, TON, T0ON, T1ON or T2ON, depending upon
which timer is used, must be set high to enable the timer to count. Depending upon which timer is
used, if TE, T0E, T1E or T2E is low, the counter will increment each time the external timer pin re-
ceives a low to high transition. If TE, T0E, T1E or T2E is high, the counter will increment each time
the external timer pin receives a high to low transition. 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
then preload the value already loaded into the preload register. Since the external timer pins are
pin-shared with other I/O pins, to ensure that these are configured to operate as event counter
pins, it is only necessary to ensure that the TM1/TM0, T0M1/T0M0, T1M1/T1M0 or T2M1/T2M0
bits place the Timer/Event Counter in the event counting mode. It should be noted that a timer over-
flow is one of the interrupt and wake-up sources.
E x te rn a l E v e n t
In c re m e n t
T im e r C o u n te r
T im e r + 1
T im e r + 2
T im e r + 3
Event Counter Mode Timing Chart
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, TM1/TM0, T0M1/T0M0, T1M1/T1M0 or T2M1/T2M0, de-
pending upon which timer is used, must both be set high. Depending upon which counter is used,
if TE, T0E, T1E or T2E is low, once a high to low transition has been received on the external timer
pin, the timer will start counting until the external timer pin returns to its original high level. At this
point the TON, T0ON, T1ON or T2ON bit, depending upon which counter is used, will be automati-
cally reset to zero and the timer will stop counting. If the TE, T0E, T1E or T2E 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 TON,
T0ON, T1ON or T2ON bit will be automatically reset to zero and the timer will stop counting. It is im-
portant to note that in the Pulse Width Measurement Mode, the TON, T0ON, T1ON or T2ON 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 TON, T0ON, T1ON or T2ON bit can only be re-
set to zero under program control. The residual value in the timer, which can now be read by the
program, therefore represents the length of the pulse received on the external timer pin. As the
TON, T0ON, T1ON or T2ON bit has now been reset, any further transitions on the external timer
pin, will be ignored. Not until the TON, T0ON, T1ON or T2ON bit is again set high by the program
can the timer begin further pulse width measurements. In this way, single shot pulse measure-
ments can be easily made. It should be noted that in this mode the counter is controlled by logical
transitions on the external timer pin and not by the logic level.
65
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index