Songhan MCU external interrupt

Publisher:星辰古泉Latest update time:2015-07-07 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
 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

Previous article:Songhan MCU timing interrupt digital tube program
Next article:8-bit resolution ADC inside Songhan MCU

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号