KS57C2308/P2308/C2316/P2316 TIMERS and TIMER/COUNTERS
11-21
++ PROGRAMMING TIP — Setting a TC0 Timer Interval
To set a 30 ms timer interval for TC0, given fxx = 4.19 MHz, follow these steps.
1. Select the timer/counter 0 mode register with a maximum setup time of 62.5 ms (assume the TC0 counter
clock = fxx/210, and TREF0 is set to FFH):
2. Calculate the TREF0 value:
30 ms = TREF0 value + 1
4.09 kHz
TREF0 + 1 = 30 ms
244 µs = 122.9 = 7AH
TREF0 value = 7AH – 1 = 79H
3. Load the value 79H to the TREF0 register:
BITS EMB
SMB 15
LD EA,#79H
LD TREF0,EA
LD EA,#4CH
LD TMOD0,EA