;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:
;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
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
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- The problem of thyristor
- EEWORLD University ---- High-speed data converter signal processing: real and complex modulation
- Principle design and application of automobile CAN bus system
- [ESP32-S2-Kaluga-1 Review] 4. Touch Audio Playback Test
- The latest developments in silicon carbide (SiC) and gallium nitride (GaN)
- The ADC sampling value of stm32f407 is always a fixed value
- I need a lithium battery current integration fuel gauge, the package cannot be larger than SOT23-6
- Fast and Furious: Longer-lasting Electric Motorcycle 16S-17S Lithium-ion Battery Pack
- Ultra-low power Bluetooth controlled, cost-effective, dimmable smart lighting solution
- The trend of integration of power control and charger functions