人狗畜禽COMPANY LIMITED|全是肉的高H文〈男男〉|全篇肉高H秘书被C办公室四爱|全黄H全肉共妻|全黄H全肉短篇禁乱NP慕浅浅|全黄H全肉短篇N男男

技術(shù)熱線: 4007-888-234
設(shè)計(jì)開發(fā)

專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命

開發(fā)工具

提供開發(fā)工具、應(yīng)用測(cè)試 完善的開發(fā)代碼案例庫(kù)分享

技術(shù)支持

從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無(wú)限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產(chǎn)品競(jìng)爭(zhēng)力

新聞中心

提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)

16F870單片機(jī)的中斷應(yīng)用程序

更新時(shí)間: 2019-03-21
閱讀量:440

點(diǎn)擊次數(shù):842次        更新時(shí)間:2012-08-22

PIC單片機(jī)

;**********************************************************************

list p=16f870

#include


; __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _RC_OSC & _WRT_ENABLE_ON & _LVP_OFF & _CPD_OFF


FLAG EQU 0x20

Var1 EQU 0x21

Var2 EQU 0x22

INT_Var1 EQU 0x30

INT_Var2 EQU 0x31

W_Temp EQU 0x72

STATUS_Temp EQU 0x73

FSR_Temp EQU 0x74

#define VAL_1MS .248

#define FLAG_INC 0

#define FLAG_DEC 1


org 0x00 ; RESET  0x000

nop

clrf PCLATH

goto Main

org 0x004

INT_ISRs

;***************************************************************

movwf W_Temp ; save off current W register contents

movf STATUS,W ; move status register into W register

bcf STATUS,RP0 ; ensure file register bank set to 0

movwf STATUS_Temp ; save off contents of STATUS register

movf FSR,W

movwf FSR_Temp


BANKSEL PORTB

movf PORTB,W

bcf INTCON,RBIF

bcf INTCON,RBIE ; RBIE Disable

call Bounce_Delay

btfsc PORTB,4

goto Check_DEC_KEY

bsf FLAG,FLAG_INC ; FLAG_INC  1

goto Exit_ISRs

Check_DEC_KEY

btfss PORTB,5

bsf FLAG,FLAG_DEC


Exit_ISRs

movf FSR_Temp,W

movwf FSR

bcf STATUS,RP0 ; ensure file register bank set to 0

movf STATUS_Temp,w ; retrieve copy of STATUS register

movwf STATUS ; restore pre-isr STATUS register contents

swapf W_Temp,F

swapf W_Temp,W ; restore pre-isr W register contents

retfie ; return from interrupt

;******************************************************************************

;**** Delay 10 ms 

;******************************************************************************

Bounce_Delay

movlw .10

movwf INT_Var1

Bounce_Loop1

movlw .248

movwf INT_Var2

Bounce_Loop2

nop

decfsz INT_Var2,F

goto Bounce_Loop2

decfsz INT_Var1,F

goto Bounce_Loop1

return

******************************************

Main

BANKSEL TRISB

movlw B'11110000'

movwf TRISB ; RB4..RB7

clrf TRISC

movlw B'00000000' ; Enable PORTB  Pull UP

movwf OPTION_REG

BANKSEL PORTB

movlw B'11111111'

movwf PORTB

clrf PORTC


bsf INTCON,GIE

clrf FLAG

bsf FLAG,FLAG_INC

Prog_Loop

btfss FLAG,FLAG_INC

goto Dec_Process


Inc_Process

call Delay_50ms

incfsz PORTC,F

goto Inc_Process

goto SLEEP_Process

Dec_Process

call Delay_50ms

decfsz PORTC,F

goto Dec_Process

SLEEP_Process

clrf PORTC

clrf FLAG

movf PORTB,W

bcf INTCON,RBIF

bsf INTCON,RBIE

SLEEP

nop

nop

goto Prog_Loop

;****************************************************************************

;**** Delay 50ms 

;****************************************************************************

Delay_50ms

movlw .50

movwf Var2

Delay_200ms_Loop

call Delay_1ms

decfsz Var2,F

goto Delay_200ms_Loop

return

;****************************************************************************

;**** Delay 1ms 

;****************************************************************************

Delay_1ms

nop

nop

nop

movlw VAL_1MS

movwf Var1

Delay_1ms_Loop nop

decfsz Var1,F

goto Delay_1ms_Loop

return


END


衡阳县| 定襄县| 年辖:市辖区| 萨嘎县| 宣恩县| 于田县| 米脂县| 黄陵县| 体育| 武定县| 涞水县| 延津县| 锦屏县| 同德县| 丰镇市| 黎城县| 福州市| 彰化市| 牙克石市| 高州市| 宝兴县| 金昌市| 泾阳县| 天门市| 无棣县| 泽库县| 定安县| 磐石市| 嘉定区| 射阳县| 响水县| 临汾市| 垫江县| 缙云县| 宁蒗| 绥江县| 普兰店市| 乌审旗| 新宁县| 通辽市| 延津县|