Advance Information
UM-TM57PE10_E
8-Bit Microcontroller
22
tenx technology inc.
Preliminary
Rev 1.4, 2012/01/19
3.3 Timer2: 15-bit Timer
The Timer2 is a 15-bit counter and the clock sources are from either Fosc/128 or slow clock. It is used to
generate time base interrupt and Timer2 counter block clock. The Timer2 content cannot be read by
instructions. It generates interrupt flag (TM2I) with the clock divided by 32768, 16384, 8192, and 128,
depends on TM2DIV register bits. Figure shows the block diagram of Timer2.
Timer2
15-bit
1
0
Fosc/128
Slow Clock
TM2CLK
RESET
Q
QB
D
TM2IE
TM2I
Timer2
Interrupt
Instruction Clear
TM2DIV[1:0]
00
01
10
11
BIT[14]
BIT[13]
BIT[12]
BIT[6]
3.4 PWM0: 8-bit PWM
The chip has a built-in 8-bit PWM generator. The source clock comes from Fosc divided by 1, 2, 4, and
8. The PWM0 duty cycle can be changed with writing to PWM0DUTY, writing to PWM0DUTY will not
change the current PWM0 duty until the current PWM0 period completes. When current PWM0 period is
finish, the new value of PWM0DUTY will be updated to the PWM0BUF.
The PWM0 will be output to PA1 if PWM0E is set to 1. Also, the PWM0 period complete will generate an
interrupt when PWM0IE is set to 1. Setting the CLRPWM0 bit will clear the PWM0 counter and load the
PWM0DUTY to PWM0BUF, CLRPWM0 bit must be cleared so that the PWM0 counter can count.
Figure shows the block diagram of PWM0.
PWM0DUTY
PWM0BUF
A
B
A<=B
PWM0PERIOD
PWM0CNT
8
A
B
A=B
PWM0IE
R
S
PA1O
PWM0O
PA1
PWM0E
PWM0I
8
8
8
8
CLRPWM0
PWM0OVF
CLRPWM0
00
01
10
11
PWM0PSC[1:0]
Fosc/1
Fosc/2
Fosc/4
Fosc/8
D
Q
1
0
CLRPWM0
CLRPWM0