82 P89C66x microcontroller Exercise 4.4 A P89C664 microcontroller has an oscillator frequency of 11.0592 MHz. Write a C program that causes timer 2 to generate an interrupt every 10 ms toggling pin 7 on port 1.
4.4 External interrupt Negative edge transitions on PORT 3 pins 2 (INT0) and 3 (INT1) can cause interrupts; their interrupt vector addresses are 03H and 13H respectively. A possible circuit arrangement is shown in Figure 4.13. Figure 4.13 shows a switch circuit where the voltage on P3.3 (port 3 pin 3) is normally 5 V. Pressing the switch causes a negative edge transition as the voltage switches down from 5 V to 0 V. If the switch is pressed and held then a logic 0 level is held on P3.3. These are the two external interrupt conditions; it can be either edge triggered (transition logic 1 to 0) or level triggered (logic 0).
+5 V DC
Microcontroller 3.3k
P3.3/INT1
GND
Figure 4.13 Circuit arrangement to produce an interrupt on port 3, pin 3. A similar arrangement can be used for port 3, pin 2
Example 4.7 A P89C664 microcontroller has an oscillator frequency of 11.0592 MHz. Write an assembly language program that complements the logic level on port 1 pin 7 when an edge triggered interrupt occurs on port 3 pin 3 (INT1). Solution The four least signiďŹ cant bits of the TCON register are used to set the external interrupt parameters. TCON TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0