English
Language : 

W921E840A Datasheet, PDF (33/58 Pages) Winbond – 4-BIT MICROCONTROLLER
W921E840A/W921C840
The format of the status of TM2 register (STTM2) is described below:
STTM2 register: (address = 02DH, default data = 0H)
b3
b2
b1
b0
Reserved
0: TM2 normal function selected
1: Special function selected
0: TM2 auto-reload disable
1: TM2 auto-reload enable
0: TM2 stop
1: TM2 start
If the TM2 is in the timer mode, TM2 will underflow when it is from 00H to 0FFH and the value in the
TM2MSB and TM2LSB will be auto reloaded to the TM2 set register. TM2 will decrease by 1 at the
frequency of timer 2 clock after timer 2 has started.
If at any time the STTM2 bit3 is from 0 to 1 (disable to enable) the TM2MSB and TM2LSB will be
auto reloaded to the TM2 set register again and restart the TM2. TM2 will stop operating when the
STTM2 bit3 is reset to 0
The TM2 starts to count when the STTM2 register bit3 is set. When TM2 underflows, the STTM2 bit3
will be reset by hardware to stop TM2 if the auto-reload is disabled, but the STTM2 bit3 will not be
reset if the auto-reload is enabled.
When the TM2 normal function is performed, the special function will be disabled automatically.
The format of the TM2 trigger condition register (TGTM2) is shown below:
TGTM2 register: (address = 02EH, default data = 0H)
b3
b2
b1
b0
b1 b0
00
01
10
11
Trigger
Rising
Falling
Both
0: Special function work as pulse/period
width measurement
1: Special function work as arbitrary
waveform generator
0: Arbitrary waveform type 0
1: Arbitrary waveform type 1
In the pulse/period width measurement mode the measuring-data is the 1'S complement of the exact
data and the TM2 interrupt flag is set every 255 timer clock past or the 2nd trigger condition occurs.
So the measured pulse/period width is (255(N − 1) + TM2) * T , N is the number of interrupt flag occurs,
TM2 is the 1'S complement of timer2 register, T is the period of timer 2 clock. The special function
input or output is from or to P5.1.
- 33 -
Publication Release Date: July 1999
Revision A3