CHAPTER 7 TIMER/COUNTER FUNCTION
User’s Manual U13850EJ6V0UD
250
7.4.5 Operation as interval timer (16 bits)
(1) Cascade connection (16-bit timer) mode
The V850/SB1 and V850/SB2 provide 16-bit registers that can be used only when connected in cascade.
The following registers are available.
TM2, TM3 cascade connection:
16-bit counter TM23 (Address: FFFFF24AH)
16-bit compare register CR23 (Address: FFFFF24CH)
TM4, TM5 cascade connection:
16-bit counter TM45 (Address: FFFFF26AH)
16-bit compare register CR45 (Address: FFFFF26CH)
TM6, TM7 cascade connection:
16-bit counter TM67 (Address: FFFFF28AH)
16-bit compare register CR67 (Address: FFFFF28CH)
By setting the TMCm4 bit 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, 7).
With the count preset in 8-bit compare register n (CRn0) as the interval, the timer operates as an interval timer
by repeatedly generating interrupts (n = 2 to 7).
The following shows a setting method when using TM2 and TM3. When using TM4 and TM5 or TM6 and TM7,
substitute them for TM2 and TM3.
Setting method (TM2, TM3 cascade connection)
(1) Setting registers
•
TCL20, TCL21:
Select the count clock for TM2 (setting not necessary for TM3 because of cascade
connection).
•
CR20, CR30:
Compare value (00H to FFH can be set for compare values)
•
TMC2:
Selects clear & start mode on a match of TM2 and CR2 (x: don’t care)
[TM2
→
TMC2 = 0000xxx0B, TM3
→
TMC3 = 0001xxx0B]
(2) Set the TCE3 bit of TMC3 to 1. After that, set the TCE2 bit of TMC2 to 1 to start the count operation.
(3) When the TM23 and CR23 values of the timer connected in cascade match, an interrupt request signal
(INTTM2) is generated (TM2 and TM3 are cleared to 00H).
(4) IMTTM2 is then repeatedly generated at the same interval.
Cautions 1. The count operation can be started or stopped just by setting the TCE2 bit of TMC2.
2.
When 8-bit timers (TM2, TM3) are connected in cascade and used as a 16-bit timer (TM23),
change the setting value of the compare register (CR23) after stopping the count operation
of the 8-bit timers connected in cascade.
If the value of CR23 is changed without stopping the timers, the values of the higher 8 bits
(TM3) become undefined.
3.
Even during cascade connection, the interrupt request signal (INTTM3) of higher timer 3
(TM3) is generated when the count value of higher timer 3 (TM3) matches CR30. Be sure to
mask TM3 to disable this interrupt.