SN8P2501D
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 76
Version 1.5
8.3.5 TC0R AUTO-RELOAD REGISTER
TC0 timer builds in auto-reload function, and TC0R register stores reload data. When TC0C overflow occurs, TC0C
register is loaded data from TC0R register automatically. Under TC0 timer counting status, to modify TC0 interval time
is to modify TC0R register, not TC0C register. New TC0C data of TC0 interval time will be updated after TC0 timer
overflow occurrence, TC0R loads new value to TC0C register. But at the first time to setup TC0M, TC0C and TC0R
must be set the same value before enabling TC0 timer. TC0 is double buffer design. If new TC0R value is set by
program, the new value is stored in 1
st
buffer. Until TC0 overflow occurs, the new value moves to real TC0R buffer.
This way can avoid any transitional condition to effect the correctness of TC0 interval time and PWM output signal.
0CDH
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
TC0R
TC0R7
TC0R6
TC0R5
TC0R4
TC0R3
TC0R2
TC0R1
TC0R0
Read/Write
W
W
W
W
W
W
W
W
After reset
0
0
0
0
0
0
0
0
The equation of TC0R initial value is as following.
TC0R initial value = 256 - (TC0 interrupt interval time * TC0 clock rate)
N is TC0 overflow boundary number. TC0 timer overflow time has five types (TC0 timer, TC0 event counter, TC0 Fcpu
clock source, PWM mode and no PWM mode). These parameters decide TC0 overflow time and valid value as follow
table.
TC0CKS PWM0 ALOAD0 TC0OUT
N
TC0R valid
value
TC0R value
binary type
0
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
1
1
1
16
0x00~0x0F
xxxx0000b~xxxx1111b
1
-
-
-
256
0x00~0xFF
00000000b~11111111b
Example: To calculation TC0C and TC0R value to obtain 10ms TC0 interval time. TC0 clock source is
Fcpu = 4MHz/4 = 1MHz. Select TC0RATE=001 (Fcpu/128).
TC0 interval time = 10ms. TC0 clock rate = 4MHz/4/128
TC0C/TC0R initial value = 256 - (TC0 interval time * input clock)
= 256 - (10ms * 4MHz / 4 / 128)
= 256 - (10
-2
* 4 * 10
6
/ 4 / 128)
= B2H