
CHAPTER 7
TIMER/COUNTER FUNCTION
User’s Manual U12768EJ4V1UD
205
7.4.5
Operation as interval timer (16 bits)
(1) Cascade connection (16-bit timer) mode
The V850/SA1 provides 16-bit registers that can be used only when connected in cascade.
The following registers are available.
TM2 to TM3 cascade connection: 16-bit counter TM23 (Address: FFFFF24AH)
16-bit compare register CR23 (Address: FFFFF24CH)
TM4 to TM5 cascade connection: 16-bit counter TM45 (Address: FFFFF26AH)
16-bit compare register CR45 (Address: FFFFF26CH)
By setting bit 4 (TMCm4) of 8-bit timer mode control register m (TMCm) to 1, the timer enters the timer/counter
mode with 16-bit resolution (m = 3, 5).
The timer operates as an interval timer by repeatedly generating interrupts (n = 2 to 5) with the count preset in 8-
bit compare register n (CRn0) as the interval.
The following is an explanation of how to use TM2 and TM3. Substitute TM4 and TM5 for TM2 and TM3 as
appropriate when using TM4 and TM5.
Example of setting method (when TM2 and TM3 are connected in cascade)
<1> Set each register.
TCL20, TCL21: Select the count clock for TM2 (TM3 does not need to be set in a cascade connection)
CR20, CR30: Compare values (each compare value can be set from 00H to FFH)
TMC2: Selects clear and start mode when TM2 and CR20 match (x: don’t care)
TM2
→ TMC2 = 0000xxx0B
TM3
→ TMC3 = 0001xxx0B
<2> Start the count operation by first setting the TCE3 bit of TMC3 to 1, and then setting the TCE2 bit of TMC2
to 1.
<3> If a match occurs between cascade-connected timer TM2 and CR20, the INTTM2 of TM2 will be generated
(TM2 and TM3 are cleared to 00H).
<4> IMTTM2 will then be generated repeatedly at the same interval.
Cautions 1. To change the set value of the compare register (CR23) while the 8-bit timers (TM2, TM3)
are connected in cascade and being used as a 16-bit timer (TM23), change the CR23 value
after stopping the count operation of each of the 8-bit timers connected in cascade. If the
CR23 value is changed without stopping the timers, the value of the higher 8 bits (TM3)
will be undefined.
2. If the count value of the higher timer (TM3) matches CR30, the higher timer (TM3) interrupt
request (INTTM3) will be generated, even when the timers are being used in a cascade
connection. TM3 must therefore always be masked to disable interrupts.
3. Set the TCE3 bit of TMC3 before setting the TCE2 bit of TMC2.
4. Restarting and stopping the count is possible just by setting the TCE2 bit of TMC2 to 1 or
0 respectively.