Example 4.6
AP89 C664 microcontroller has an oscillator frequency of 11.0592 MHz. Write
a program that causes timer 2 to generate an interrupt every 10 ms toggling
pin 7 on port 1.
Solution
Oscillator frequency ¼ 11:0592MHz
Therefore timer clock ¼ 1:8432MHz
Timer clock cycle ¼ 542:54 ns
Delay time count ¼ 10 ms/542:54 ns ¼ 18432 (nearest whole number)
Timer 2 base number ¼ 65535 18432 ¼ 47103 decimal ¼ B7FFH
In timer 2 the reload register for TH2 is RCAP2H (capture register 2) and the
reload register for TL2 is RCAP2L. ET2 in IEN1 enables timer 2 interrupt.