chip sn8f27e65
//{{SONIX_CODE_OPTION
//Full source code download: http://www.51hei.com/f/shwbzd.rar
.Code_Option WDT_CLK Flosc/4
.Code_Option Reset_Pin P04
.Code_Option LVD LVD_Max ; 3.3V Reset
.Code_Option Watch_Dog Disable ;Turn off watchdog.Code_Option
Low_Fcpu Flosc/1
.Code_Option High_Clk IHRC_16M ; Internal 16M RC Oscillator
.Code_Option High_Fcpu Fhosc/1
.Code_Option Security Enable
.Code_Option Noise_Filter Enable
//}}SONIX_CODE_OPTION
.DATA;Data
ORG 0
TEMP DS 1
ACCBUF DS 1
PflagBUF DS 1
K DS 1
.CONST
K1 EQU K.0; Flag bit
.CODE; Program code
ORG 0000H
JMP A1
ORG 09H; External interrupt entry
JMP INT00
A1: MOV A, #02H; Set the interrupt trigger mode to low level trigger
B0MOV PEDGE, A
B0BCLR FP00IRQ ; Clear interrupt flag
B0BSET FP00IEN; Enable interrupt
B0BSET FGIE; Enable general interrupt
B0BSET K1; Set flag
JMP $
; ****************************** **********************
;Interrupt service routine
; ************************** **************************
INT00:
B0BCLR FP00IEN; disable interrupt
B0BCLR FGIE; disable interrupt
B0XCH A,ACCBUF; push stack
B0MOV A,PFLAG;
B0MOV PFLAGBUF,A;
B0BTS1 FP00IRQ; Determine whether an interrupt
JMP actually occurs INT01
B0BTS1 K1; judge the flag to control the LED status flag is 1 LED is on
JMP K01
B0BCLR K1; clear the flag to 0
B0BSET P0M.3; set P0.3 to output mode
B0BCLR P0.3; turn on the LED
;******** ************************************
;Key debounce
;********* **********************************
K00: CALL M001; Delay
B0BCLR P0M.0; Set P0.0 Input mode
B0BSET P0UR.0; Set P0.0 to pull up
B0BTS1 P0.0; Determine whether P0.0 is 0 to continue or not to skip the next instruction
JMP K00
CALL M001
B0BCLR P0M.0
B0BSET P0UR.0
B0BTS1 P0.0 ; Determine whether P0.0 is 0 and whether to continue or skip the next instruction
JMP K00
JMP INT01
K01:
B0BTS0 K1
JMP INT01
B0BSET K1
B0BSET P0M.3
B0BSET P0.3
K02:
CALL M001
B0BCLR P0M.0
B0BSET P0UR.0
B0BTS1 P0.0; Determine whether P4.0 is 1 and whether to continue or skip the next instruction
JMP K02
CALL M001
B0BCLR P0M.0
B0BSET P0UR.0
B0BTS1 P0.0; Check if P4.0 is 1, whether to continue or not, skip the next instruction
JMP K02
INT01:
B0MOV A,PFLAGBUF; Pop stack
B0MOV PFLAG,A
B0XCH A,ACCBUF
B0BCLR FP00IRQ
B0BSET FP00IEN
B0BSET FGIE
RETI
;*************************************************
; Delay subroutine
;*********************************************
M001: MOV A,#200
MOV 50H,A
M002: MOV A,#250
MOV 51H,A
M003: DECMS 51H
JMP M003
DECMS 50H
JMP M002
RET
ENDP
Reference address:Songhan MCU external interrupt
//{{SONIX_CODE_OPTION
//Full source code download: http://www.51hei.com/f/shwbzd.rar
.Code_Option WDT_CLK Flosc/4
.Code_Option Reset_Pin P04
.Code_Option LVD LVD_Max ; 3.3V Reset
.Code_Option Watch_Dog Disable ;Turn off watchdog.Code_Option
Low_Fcpu Flosc/1
.Code_Option High_Clk IHRC_16M ; Internal 16M RC Oscillator
.Code_Option High_Fcpu Fhosc/1
.Code_Option Security Enable
.Code_Option Noise_Filter Enable
//}}SONIX_CODE_OPTION
.DATA;Data
ORG 0
TEMP DS 1
ACCBUF DS 1
PflagBUF DS 1
K DS 1
.CONST
K1 EQU K.0; Flag bit
.CODE; Program code
ORG 0000H
JMP A1
ORG 09H; External interrupt entry
JMP INT00
A1: MOV A, #02H; Set the interrupt trigger mode to low level trigger
B0MOV PEDGE, A
B0BCLR FP00IRQ ; Clear interrupt flag
B0BSET FP00IEN; Enable interrupt
B0BSET FGIE; Enable general interrupt
B0BSET K1; Set flag
JMP $
; ****************************** **********************
;Interrupt service routine
; ************************** **************************
INT00:
B0BCLR FP00IEN; disable interrupt
B0BCLR FGIE; disable interrupt
B0XCH A,ACCBUF; push stack
B0MOV A,PFLAG;
B0MOV PFLAGBUF,A;
B0BTS1 FP00IRQ; Determine whether an interrupt
JMP actually occurs INT01
B0BTS1 K1; judge the flag to control the LED status flag is 1 LED is on
JMP K01
B0BCLR K1; clear the flag to 0
B0BSET P0M.3; set P0.3 to output mode
B0BCLR P0.3; turn on the LED
;******** ************************************
;Key debounce
;********* **********************************
K00: CALL M001; Delay
B0BCLR P0M.0; Set P0.0 Input mode
B0BSET P0UR.0; Set P0.0 to pull up
B0BTS1 P0.0; Determine whether P0.0 is 0 to continue or not to skip the next instruction
JMP K00
CALL M001
B0BCLR P0M.0
B0BSET P0UR.0
B0BTS1 P0.0 ; Determine whether P0.0 is 0 and whether to continue or skip the next instruction
JMP K00
JMP INT01
K01:
B0BTS0 K1
JMP INT01
B0BSET K1
B0BSET P0M.3
B0BSET P0.3
K02:
CALL M001
B0BCLR P0M.0
B0BSET P0UR.0
B0BTS1 P0.0; Determine whether P4.0 is 1 and whether to continue or skip the next instruction
JMP K02
CALL M001
B0BCLR P0M.0
B0BSET P0UR.0
B0BTS1 P0.0; Check if P4.0 is 1, whether to continue or not, skip the next instruction
JMP K02
INT01:
B0MOV A,PFLAGBUF; Pop stack
B0MOV PFLAG,A
B0XCH A,ACCBUF
B0BCLR FP00IRQ
B0BSET FP00IEN
B0BSET FGIE
RETI
;*************************************************
; Delay subroutine
;*********************************************
M001: MOV A,#200
MOV 50H,A
M002: MOV A,#250
MOV 51H,A
M003: DECMS 51H
JMP M003
DECMS 50H
JMP M002
RET
ENDP
Previous article:Songhan MCU timing interrupt digital tube program
Next article:8-bit resolution ADC inside Songhan MCU
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Guess you like
- MicroPython's "Season of Docs" project
- Please recommend a step-down circuit
- C6000 Cache
- FPGA_100 Days_Binary to Decimal
- What parameters determine the emission distance of the infrared transmitter tube?
- Msp430PID control motor speed programming example
- A New Decision Feedback Equalizer Architecture Based on FPGA
- Reply and give points: 5G is coming, will you change to a 5G mobile phone?
- Application of ultra-high threshold voltage depletion-mode MOSFET DMZ0615E in mobile phone fast charging
- Forum member long521's niece is sick, please help her!