CHAPTER 13 PERIPHERAL HARDWARE
123
(2) Calculation method of count value
The time interval of the identity signal being emitted from the comparator is determined by the value that
is set in the modulo register. The formula for finding the value N of the modulo register from the time interval
T [sec] is shown below:
T=
= (N+1)
×
T
CP
N=T
×
f
CP
–1 or N= –1 (N=1 to 255)
f
CP
: Count pulse's frequency [Hz]
T
CP
: Count pulse's frequency [sec] (1/f
CP
= resolution)
(3) Calculation example and program example when calculating count value by interval time
•
Example of assuming 7 ms as interval time for timer (System clock: f
X
=8 MHz)
Assuming 7 ms as interval time, it is impossible to set 7 ms interval time from the resolution of the timer.
Therefore, count value should be calculated by selecting the source clock the resolution of which is
maximum (f
X
/256, resolution: 32
µ
s) to set the nearest interval time.
Example
t=7 ms, resolution: 32
µ
s
N =
–1
=
– 1
= 217.75=218 (: DAH)
The value of modulo register the interval time of which becomes nearest to 7 ms is DAH, and the interval
time at that time becomes 7.008 ms.
f
CP
N+1
T
T
CP
t
(Resolution)
7
×
10
–3
32
×
10
–5
Summary of Contents for mPD17120 Subseries
Page 15: ... x MEMO ...
Page 23: ... MEMO 8 ...
Page 45: ... MEMO 30 ...
Page 49: ... MEMO 34 ...
Page 55: ... MEMO 40 ...
Page 93: ... MEMO 78 ...
Page 99: ... MEMO 84 ...
Page 102: ...CHAPTER 11 ARITHMETIC AND LOGIC UNIT 87 MEMO ...
Page 119: ... MEMO 104 ...
Page 175: ... MEMO 160 ...
Page 199: ... MEMO 184 ...
Page 265: ... MEMO 250 ...
Page 281: ...266 MEMO ...
Page 285: ... MEMO 270 ...
Page 289: ... MEMO 274 ...