R01UH0092EJ0110 Rev.1.10
Page 327 of 807
Jul 31, 2012
M16C/64C Group
18. Timer B
18.5.4
Timer B (Pulse Period/Pulse Width Measurement Modes)
18.5.4.1
MR3 Bit in the TBiMR Register
To clear the MR3 bit to 0 by writing to the TBiMR register while the TBiS bit is 1 (count started), be
sure to set the same value as previously set to bits TMOD0, TMOD1, MR0, MR1, TCK0, and TCK1,
and set bit 4 to 0.
18.5.4.2
Interrupts
The IR bit in the TBiIC register becomes 1 (interrupt requested) when an active edge of a
measurement pulse is input, or timer Bi overflows (i = 0 to 5). The source of an interrupt request can
be determined by setting the MR3 bit in the TBiMR register within the interrupt routine.
Use the IR bit in the TBiIC register to detect overflows only. Use the MR3 bit only to determine the
interrupt source.
18.5.4.3
Event or Trigger
When timer Bi in pulse-period measurement mode or pulse-width measurement mode is used as an
event or trigger for timer A or timer B other than timer Bi, an event or trigger occurs at both the
overflow and active edge of the measurement pulse.
18.5.4.4
Operations between Count Start and the First Measurement
When a count is started and the first active edge is input, an undefined value is transferred to the
reload register. At this time, a timer Bi interrupt request is not generated.
The value of the counter is undefined after reset. If the count is started in this state, the MR3 bit may
become 1 and a timer Bi interrupt request may be generated after the count starts before an active
edge is input. When a value is set in the TBi register while the TBiS bit is 0 (count stopped), the same
value is written to the counter.
18.5.4.5
Pulse Period Measurement Mode
When an active edge and overflow are generated simultaneously, input is not recognized at the
active edge because an interrupt request is generated only once. Use this mode
so
an overflow is not
generated, or use pulse width measurement mode.
18.5.4.6
Pulse Width Measurement Mode
In pulse width measurement, pulse widths are measured successively. Check whether the
measurement result is a high-level width or a low-level width in the user program.
When an interrupt request is generated, read the TBiIN pin level in the interrupt routine, and check
whether it is the edge of an input pulse or overflow. The TBiIN pin level can be read from bits in the
register of ports sharing a pin.
Summary of Contents for M16C Series
Page 846: ...M16C 64C Group R01UH0092EJ0110...