Module 5 : Experiments on Microcontrollers

Lecture 41 : External Interrupt with AT89C51

 

Aim

To toggle LEDs connected to two port pins (say P1.0 &P1.1) 5 times under the control of external interrupt (say External Interrupt 0)

Components/Software

  1. Atmel 89C51 micro controller
  2. 8051 simulator win8051
  3. Universal SP3 Programmer.
  4. Software to load the code into Universal SP3 Programmer.
  5. Computer System with Windows operating system and RS 232 Cable.
  6. +5V D.C Power Supply
  7. SPST switches-2
  8. Resistors-8.2k-1
  9. Capacitors-30pF-2, 10uF-1
  10. 10MHz crystal
  11. LEDs-2
Procedure
  1. Write the assembly code in win8051 simulator , compile it and check for errors
  2. Once the code is error free, run it and check the output.
  3. After checking the code in the simulator, the code (in .hex format) was loaded into Atmel 89c51 microcontroller using Universal SP3 Programmer.
  4. Now make the connections as shown in the circuit diagram.
  5. After switching on the power supply, press the push button switch connected to P3.2(INT0) once and observe the toggling of both the LEDs connected to P1.0 & P1.1 by 5 times.
  6. Repeat the step -5 once more and again observe the same output.
Method
The external interrupt - 0 () is enabled. Whenever the switch connected to   (P3.2)  is pressed, an interrupt is generated and the program branches to the Interrupt Service Routine(ISR)  located at 0003H. The ISR toggles the LED connected to P1.0 and P1.1 and returns to the main program.
Assembly Code
Observation

The toggling frequency of the LEDs is measured in the CRO which was same as that of the delay loop time.

Conclusion

Two LEDs were toggled 5 times, each time when we press push buttion switch connected to P3.2 (INT0).

Circuit Diagram

Fig 41.1 Circuit diagram of toggling LEDs experiment