SN8P2740 Series
ADC, OP-amp, Comparator 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 78
Version 2.0
T0 clock source is Fcpu (instruction cycle) through T0rate[2:0] pre-scaler to decide Fcpu/2~Fcpu/256. T0 length is 8-bit
(256 steps), and the one count period is each cycle of input clock.
T0rate[2:0]
T0 Clock
T0 Interval Time
Fhosc=16MHz,
Fcpu=Fhosc/4
Fhosc=16MHz,
Fcpu=Fhosc/16
max. (ms) Unit (us) max. (ms) Unit (us)
000b
Fcpu/256
16.384
64
65.536
256
001b
Fcpu/128
8.192
32
32.768
128
010b
Fcpu/64
4.096
16
16.384
64
011b
Fcpu/32
2.048
8
8.192
32
100b
Fcpu/16
1.024
4
4.096
16
101b
Fcpu/8
0.512
2
2.048
8
110b
Fcpu/4
0.256
1
1.024
4
111b
Fcpu/2
0.128
0.5
0.512
2
8.2.3 T0M MODE REGISTER
T0M is T0 timer mode control register to configure T0 operating mode including T0 pre-
scaler, clock source…These
configurations must be setup completely before enabling T0 timer.
0D8H
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
T0M
T0ENB
T0rate2
T0rate1
T0rate0
-
-
-
-
Read/Write
R/W
R/W
R/W
R/W
-
-
-
-
After reset
0
0
0
0
-
-
-
-
Bit [6:4]
T0RATE[2:0]:
T0 timer clock source select bits.
000 = Fcpu/256, 001 = Fcpu/128, 010 = Fcpu/64, 011 = Fcpu/32, 100 = Fcpu/16, 101 = Fcpu/8, 110 =
Fcpu/4,111 = Fcpu/2.
Bit 7
T0ENB:
T0 counter control bit.
0 = Disable T0 timer.
1 = Enable T0 timer.
8.2.4 T0C COUNTING REGISTER
T0C is T0 8-bit counter. When T0C overflow occurs, the T0IRQ flag is set as
“1” and cleared by program. The T0C
decides T0 interval time through below equation to calculate a correct value. It is necessary to write the correct value to
T0C register, and then enable T0 timer to make sure the fist cycle correct. After one T0 overflow occurs, the T0C
register is loaded a correct value by program.
0D9H
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
T0C
T0C7
T0C6
T0C5
T0C4
T0C3
T0C2
T0C1
T0C0
Read/Write
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
After reset
0
0
0
0
0
0
0
0
The equation of T0C initial value is as following.
T0C initial value = 256 - (T0 interrupt interval time * T0 clock rate)
Example: To calculation T0C to obtain 10ms T0 interval time. T0 clock source is Fcpu = 16MHz/16 = 1MHz.
Select T0RATE=001 (Fcpu/128).
T0 interval time = 10ms. T0 clock rate = 16MHz/16/128
T0C initial value = 256 - (T0 interval time * input clock)
= 256 - (10ms * 16MHz / 16 / 128)
= 256 - (10
-2
* 16MHz / 16 / 128)
= B2H