Application of 2 external interrupts of 51 MCU

Publisher:朱颜素韵Latest update time:2020-06-19 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;There are 8 LEDs connected to the P1 port of the 51 microcontroller.

;A push button switch K1 is connected to the external interrupt 0 input pin P3.2.

;A push button switch K2 is connected to the external interrupt 1 input pin P3.3.

; When K1 and K2 are not pressed, the 8 LEDs at port P1 will display as running lights.

;When only K1 (P3.2) is pressed, the 4 LEDs on the left and right flash alternately.

;When only K2 (P3.3) is pressed, all 8 LEDs of P1 port will flash.

;The two external interrupts have the same priority.

;=============================================

;The PROTSUE simulation interface is as follows:

Application of 2 external interrupts of 51 MCU - Non-famous blogger - Electronic Information Corner

;Image link: http://hi.baidu.com/%D7%F6%B6%F8%C2%DB%B5%C0/album/item/50c618c5f08ba9f48026ac6a.html#

;The following procedures can meet the requirements.


      ORG 0000H

      SJMP MAIN

      ORG 0003H

      SJMP X0_INT

      ORG 0013H

      SJMP X1_INT

;------------------------------------

MAIN:

      MOV SP, #60H

      MOV IE, #85H

      MOV A, #254

M_LOOP:

      MOV P1, A

      RL A

      CALL DL_500MS

      SJMP M_LOOP

;------------------------------------

X0_INT:

      PUSH PSW

      SETB RS1

      MOV P1, #0FH

SH_0:

      XRL P1, #255

      CALL DL_500MS

      JNB P3.2, SH_0

      POP PSW

      RETI

;------------------------------------

X1_INT:

      PUSH PSW

      SETB RS0

      MOV P1, #0

SH_1:

      XRL P1, #255

      CALL DL_500MS

      JNB P3.3, SH_1

      POP PSW

      RETI

;------------------------------Delay subroutine

DL_500MS:

      MOV R5, #9 ;1T

DL1: MOV R6, #128 ;1T

DL2: MOV R7, #215 ;1T

      NOP ;1T

DL3: DJNZ R7, DL3; 2T 2 * 215 = 430 T

      DJNZ R6, DL2 ;2T [1+1+430+2] * 128 = 55552 T

      DJNZ R5, DL1 ;2T [1+55552+2] * 9 = 499995 T

      RET ;2T 1 + 499995 + 2 = 499998 T

;------------------------------------

END

Reference address:Application of 2 external interrupts of 51 MCU

Previous article:[MCU Notes] Single button to achieve single click, double click, long press
Next article:89C51 MCU external interrupt 0, 1 control LED

Recommended ReadingLatest update time:2024-11-23 08:18

How to Write a Music Program for 51 Single Chip Microcomputer
I just made a music program and would like to contribute it to you. I hope you will be satisfied. The circuit connection is very simple. Connect a buzzer to the P3.0 port, but the effect is average. If you want a better effect, add an amplifier circuit and connect a low-power speaker. Because it is not convenient to p
[Microcontroller]
MCS-51 series enhanced single chip microcomputer
     Intel has introduced enhanced series products based on the three basic products of the MCS-51 series, namely the 52 sub-series, with typical products being: 8032/8052/8752. Their internal RAM has been increased to 256B, the on-chip program memory of 8052 and 8752 has been expanded to 8KB, the number of 16-bit tim
[Microcontroller]
MCS-51 series enhanced single chip microcomputer
Common problems and solutions for LED display luminous characters
   1. Short LED life: The theoretical life of LED produced by regular manufacturers is generally about 80,000 hours. However, many luminous characters now frequently replace LED modules before they are used for a year, which brings a lot of trouble and economic losses to customers and advertising producers.   Solut
[Power Management]
51 MCU 18b20 temperature and key adjustable upper and lower limit alarm source program
The 18b20 displays 2-digit temperature and upper and lower limits, over-limit alarm, and the upper and lower limits of temperature can be adjusted. The source program of the microcontroller with flashing light is as follows: #include reg52.h #define uchar unsigned char #define uint unsigned int sbit ds=P2^2;     
[Microcontroller]
Introducing several solutions for automotive interior and exterior lighting LED drivers
introduction LED (Light Emitting Diode) is a solid-state semiconductor device that can directly convert electricity into light. In recent years, its application areas have been continuously broadened, from traditional portable device backlight to medium and large-sized LCD monitor/LCD TV backlight, automotive a
[Power Management]
Introducing several solutions for automotive interior and exterior lighting LED drivers
Typical LED dimmable circuit module design
  Many LED lamps are advertised as dimmable, but in reality, the performance of many LED lamps is not very ideal and varies depending on the dimmer used and the circuit load. Sometimes, when LED lamps are installed in a room with a dimmer, the LED lamps will flicker and the brightness cannot be adjusted evenly. The dr
[Power Management]
Typical LED dimmable circuit module design
Learn 51 MCU from me (V): MCU dynamic scanning drive digital tube
  1. Summary of this article   The fourth issue of this magazine introduced the principle of connecting a single-chip microcomputer to an external keyboard and gave an application example. This issue will introduce the dynamic driving of segment digital tubes by single-chip microcomputers. Through this lecture, reade
[Microcontroller]
Learn 51 MCU from me (V): MCU dynamic scanning drive digital tube
Current status of white light LEDs and analysis of losses during LED use
LED is called the fourth generation lighting source or green light source. It has the characteristics of energy saving, environmental protection, long life and small size. It can be widely used in various indication, display , decoration, backlight, general lighting and urban night scene. In recent yea
[Power Management]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号