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 program
//{{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:Single chip microcomputer timing interrupt digital tube program
Next article:8-bit resolution ADC inside Songhan MCU
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
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
- 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
MoreDaily News
- 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
Guess you like
- What will happen if you input a non-existent time into the real-time clock DS1302?
- [Shanghai Hangxin ACM32F070 development board + touch function evaluation board] 01. Basic engineering & KEY & LED & BUZZER & SHELL
- Complain about the search engine you currently use...
- Borrowing a power bank for 99 yuan a day is really a rip-off? Have you ever used a shared power bank?
- KiCad 5.1.7 was officially released on September 30th
- C2000 Real-time Control MCU Application in Electric Vehicles
- Qorvo's Zhou Ting: Towards an ideal ultra-broadband provider
- "It's OK as long as it works, what else do you need?" ST Industry Summit 2019 answer sheet completed and sent a mouse disassembly diagram
- Smart electric car seesaw
- Ultrasonic drive circuit