TIMER B
8.5 Pulse period/Pulse width measurement mode
8.5.1 Setting for pulse period/pulse width measurement mode
Figure 8.5.2 shows an initial setting example for registers relevant to the pulse period/pulse width measurement
mode.
Note that when using interrupts, set up to enable the interrupts. For details, refer to “CHAPTER 6.
INTERRUPTS.”
Selecting pulse period/pulse width measurement mode and each function
b7
b0
Timer Bi mode register (i = 0 to 2)
(Addresses 5B16 to 5D16) (Note 1)
1
0
Selection of pulse period/pulse width measurement mode
Measurement mode select bits
b3 b2
0 0 : Pulse period measurement (Interval between falling edges
of measurement pulse)
0 1 : Pulse period measurement (Interval between rising edges
of measurement pulse)
1 0 : Pulse width measurement
1 1 : Do not select.
Count-type select bit
0: Counter clear type
1: Free-run type
Timer Bi overflow flag (Note 2)
0: No overflow
1: Overflowed
Count source select bits
b7b6
0 0 : f
2
0 1 : f16
1 0 : f64
1 1 : f512
Setting interrupt priority level
b7
b0
Timer Bi interrupt control register (i = 0 to 2)
(Addresses 7A16 to 7C16)
Interrupt priority level select bits
When using interrupts, set these bits to one of levels 1 to 7.
When disabling interrupts, set these bits to level 0.
When a pin is allocated to a port P2 pin (Note 3)
Setting port P2 direction register
When a pin is allocated to a port P5 pin (Note 3)
Setting port P5 direction register
b7
b0
b7
b0
Port P5 direction register (Address D16
)
Port P2 direction register (Address 816
)
Pin TB0IN
Pin TB0IN
Clear the coressponding bit to “0.”
Clear the coressponding bit to “0.”
Pin TB1IN
Pin TB2IN
Pin TB1IN
Pin TB2IN
Setting count start bit to “1”
b7
b0
Count start register 0
(Address 4016)
Timer B0 count start bit
Timer B1 count start bit
Timer B2 count start bit
Count starts.
Notes 1: When using timer B2, be sure to clear the timer B2 clock source select bit (See Figure 8.4.2.) to “0.”
2: The timer Bi overflow flag is a read-only bit. This bit is undefined after reset. When a value is written to the timer Bi mode register
with the count start bit = “1,” this bit will be cleared to “0.”
3: By using bits 0 to 2 of the port P2 pin function control register (address AE16), be sure to set the pin allocation. (See Figure 8.2.5.)
Fig. 8.5.2 Initial setting example for registers relevant to pulse period/pulse width measurement mode
7906 Group User’s Manual Rev.2.0
8-22