SN8P2711A
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 95
Version 0.1
8.3.5 TC1R AUTO-LOAD REGISTER
TC1 timer is with auto-load function controlled by ALOAD1 bit of TC1M. When TC1C overflow occurring, TC1R value
will load to TC1C by system. It is easy to generate an accurate time, and users don’t reset TC1C during interrupt
service routine.
TC1 is double buffer design. If new TC1R value is set by program, the new value is stored in 1
st
buffer. Until TC1
overflow occurs, the new value moves to real TC1R buffer. This way can avoid TC1 interval time error and glitch in
PWM and Buzzer output.
Note: Under PWM mode, auto-load is enabled automatically. The ALOAD1 bit is selecting overflow
boundary.
0DEH
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
TC1R
TC1R7 TC1R6 TC1R5 TC1R4 TC1R3 TC1R2 TC1R1 TC1R0
Read/Write
W W W W W W W W
After
reset
0 0 0 0 0 0 0 0
The equation of TC1R initial value is as following.
TC1R initial value = N - (TC1 interrupt interval time * input clock)
N is TC1 overflow boundary number. TC1 timer overflow time has six types (TC1 timer, TC1 event counter, TC1 Fcpu
clock source, TC1 Fosc clock source, PWM mode and no PWM mode). These parameters decide TC1 overflow time
and valid value as follow table.
TC1CKS TC1X8 PWM1
ALOAD1 TC1OUT
N
TC1R valid
value
TC1R value
binary type
0 x x 256
0x00~0xFF
00000000b~11111111b
1 0 0 256
0x00~0xFF
00000000b~11111111b
1 0 1 64
0x00~0x3F
xx000000b~xx111111b
1 1 0 32
0x00~0x1F
xxx00000b~xxx11111b
0
(Fcpu/2~
Fcpu/256)
1 1 1 16
0x00~0x0F
xxxx0000b~xxxx1111b
0 x x 256
0x00~0xFF
00000000b~11111111b
1 0 0 256
0x00~0xFF
00000000b~11111111b
1 0 1 64
0x00~0x3F
xx000000b~xx111111b
1 1 0 32
0x00~0x1F
xxx00000b~xxx11111b
0
1
(Fosc/1~
Fosc/128)
1 1 1 16
0x00~0x0F
xxxx0000b~xxxx1111b
1 - -
- - 256
0x00~0xFF
00000000b~11111111b
¾
Example: To set 10ms interval time for TC1 interrupt. TC1 clock source is Fcpu (TC1KS=0, TC1X8=0) and
no PWM output (PWM1=0). High clock is external 4MHz. Fcpu=Fosc/4. Select TC1RATE=010 (Fcpu/64).
TC1R initial value = N - (TC1 interrupt interval time * input clock)
= 256 - (10ms * 4MHz / 4 / 64)
= 256 - (10
-2
* 4 * 10
6
/ 4 / 64)
= 100
= 64H