![](http://datasheet.mmic.net.cn/30000/M37905M4C-XXXFP_datasheet_2360025/M37905M4C-XXXFP_167.png)
7905 Group User’s Manual Rev.1.0
8-16
TIMER B
8.4 Event counter mode
8.4.2 Setting for event counter mode
Figure 8.4.3 shows an initial setting example for registers relevant to the event counter mode.
Note that when using interrupts, set up to enable the interrupts. For details, refer to section “CHAPTER
6. INTERRUPTS.”
Fig. 8.4.3 Initial setting example for registers relevant to event counter mode
Note: The counter divides the count source by (n + 1).
Setting division ratio
b7
b0
Can be set to “000016” to “FFFF16” (n).
(b15)
(b8)
b7
b0
Timer B0 register (Addresses 5116, 5016)
Timer B1 register (Addresses 5316, 5216)
Timer B2 register (Addresses 5516, 5416)
Count starts.
b7
b0
0 0 : Count at falling edge of external signal.
0 1 : Count at rising edge of external signal.
1 0 : Count at both of falling and rising edges of external signal.
1 1 : Do not selected.
01
Selecting event counter mode and count polarity
Timer Bi mode register (i = 0 to 2) (Addresses 5B16 to 5D16)
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.
: It may be either “0” or “1.”
Selection of event counter mode
Count polarity select bits
Selecting clock source
b7
b0
Particular function select register 1
(Address 6316)
Timer B2 clock source select bit
0 : Count an external signal input to the TB2IN pin
1 : Count fX32
Timers B0 and B1
Timer B2
0
Setting port P2 direction register
b7
b0
P2 direction register (Address 816)
Clear the corresponding bit to
“0.”
(Note 2)
Pin TB0IN
Pin TB1IN
Pin TB2IN
When a pin is allocated to a port P2 pin (Note 1)
Setting port P5 direction register
b7
b0
P5 direction register (Address D16)
Clear the corresponding bit to
“0.”
(Note 2)
Pin TB0IN
Pin TB1IN
Pin TB2IN
When a pin is allocated to a port P5 pin (Note 1)
Notes 1: 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.)
2: When fX32 is selected as the count source in timer B2 (in other words, when bit 6 at address 6316 = 1), this setting is unnecessary.