
7905 Group User’s Manual Rev.1.0
8-22
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.”
Fig. 8.5.2 Initial setting example for registers relevant to pulse period/pulse width measurement mode
Count starts.
b7
b0
Measurement mode select bits
10
Selecting pulse period/pulse width measurement mode and each function
Timer Bi mode register (i = 0 to 2)
(Addresses 5B16 to 5D16) (Note 1)
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
b3 b2
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.
Count source select bits
b7b6
Timer Bi overflow flag (Note 2)
0: No overflow
1: Overflowed
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.
0 0 : f2
0 1 : f16
1 0 : f64
1 1 : f512
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.)
Selection of pulse period/pulse width measurement mode
Count-type select bit
0: Counter clear type
1: Free-run type
Setting port P2 direction register
b7
b0
Port P2 direction register (Address 816)
Clear the coressponding bit to “0.”
Pin TB0IN
Pin TB1IN
Pin TB2IN
When a pin is allocated to a port P2 pin (Note 3)
Setting port P5 direction register
b7
Port P5 direction register (Address D16)
Clear the coressponding bit to “0.”
Pin TB0IN
Pin TB1IN
Pin TB2IN
b0
When a pin is allocated to a port P5 pin (Note 3)