COUNT EQU 9217 ;For the crystal oscillator of 11.0592, the delay is 10ms
LED1 EQU P1.1
LED2 EQU P1.3 ;Used as the display of external interrupt 0
;
ORG 0000H
LJMP RESET ;Jump to the initialization program
ORG 0003H ; INT0 (external interrupt 0)
LJMP INT_ET0 ;Jump to the external interrupt 0 service program (this program interrupt is entered from here)
ORG 000BH ;TIMER0 (timer/counter T0)
LJMP INT_TIMER0 ;Jump to the timer/counter interrupt service program
// ORG 0013H ;External interrupt 1
// RETI ;Interrupt return instruction
// ORG 001BH ;TIMER1 (timer/counter T1)
// RETI
// ORG 0023H ;Serial port interrupt
// RETI
;
ORG 0030H
RESET: MOV R0,#00H
DJNZ R0,$ ;At the beginning, a small delay is performed to prepare various working registers
SETB LED1
SETB LED2
;Set timer interrupt
MOV TMOD,#00000001B
MOV TH0,#HIGH(65536-COUNT)
MOV TL0,#LOW(65536-COUNT)
//MOV TH0,#(65536-COUNT)/256;Get the high eight bits of data
// MOV TL0,#255 ;Get the bottom five bits (the largest)
CLR TF0 ;Clear the overflow flag first
SETB TR0 ;Start timing
SETB ET0 ;ET0 is the overflow interrupt enable bit of timer/counter T0
;Set external interrupt 0
SETB IT0 ;Set external interrupt 0 as jump trigger mode
CLR IE0
SETB EX0
SETB EA
MOV IP,#00000001B; Set PX0 to high priority interrupt (external interrupt 0)
MOV R1,#00H; Used as timer accumulator
LOOP: SJMP LOOP ;Wait here
;
;IE0=1
INT_ET0://CLR LED2
CPL TR0
//CPL LED1
ACALL DELAY
CLR IE0
CPL LED2
RETI
;TF0=1
INT_TIMER0:
INC R2 ;Increment R1 by one
CLR TF0 ;CLEAR TF0 AGAIN
MOV TH0,#(65536-COUNT)/256;Get the high eight bits
MOV TL0,#255 ;Get the bottom five bits (the maximum)
CJNE R2,#10,L0; If not equal, transfer instruction, this number can be adjusted
CPL LED1; Invert instruction
MOV R2, #00H
L0: RETI
;Delay subroutine, 12M crystal delay is about R4
DELAY: ;Approximate value: 2us*256*256*2=260ms, can also be considered as 250ms
PUSH PSW ;Site protection instruction (sometimes it can be omitted)
MOV R4,#4
L3: MOV R2 ,#00H
L1: MOV R3 ,#00H
L2: DJNZ R3 ,L2 ;Innermost loop: (256 times) 2 cycle instructions (R3 minus one, if greater than 1, turn to L2)
DJNZ R2 ,L1 ;Middle loop: 256 times
DJNZ R4 ,L3 ;Outer loop: 2 times
POP PSW
RET
END
Previous article:Buzzer control advanced program
Next article:MCU assembly interrupt program (timer interrupt)
Recommended ReadingLatest update time:2024-11-16 14:31
- Popular Resources
- Popular amplifiers
- STC8 series MCU development guide: analysis and application of processors, programming and operating systems
- Compilation system perspective: Graphical explanation of the working mechanism and implementation principle of the GCC compiler
- Principles of Compilation 3rd Edition (Zhang Suqin, Wang Shengyuan, Dong Yuan, Lü Yingzhi, Jiang Weidu)
- Decompilation technology and software reverse analysis
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Please explain the assembly program of digital voltmeter
- Touch screen interface definition
- 2. [Learning LPC1768 library functions] Keystroke experiment
- How to change UDP point-to-point communication to UDP broadcast communication
- Design of a USB reader based on embedded system
- [NXP Rapid IoT Review] + NXP Rapid IoT interface design process
- After staying up late to sort it out, here is the information of the electric cars on the national competition list
- Analysis of 2017 Signal Source Competition Topic
- Circuit-level electrostatic protection design techniques and ESD protection methods
- There are three questions about LC series-parallel circuit, transistor static operating point, and 4G 5G diffraction capability.