PIC中斷匯編例程
listp=16f876
本文引用地址:http://m.butianyuan.cn/article/201611/316245.htm#include
;--------------------------
;定時(shí)計(jì)數(shù)單元
HW_TIMEEQU0X40
;-----------------------------
;定時(shí)常數(shù)
HW_TIMECT0EQU0XDF;TMR0定時(shí)器時(shí)間常數(shù),載波信號(hào)頻率37.88KHz(13.2us)
HW_TIMECT1EQU0X64;發(fā)送信號(hào)位間隔,*(1.32ms)
HW_TIMECT3EQU0X31;
;-------------------------------------
ORG0X00
GOTOHW_RECEIVE
;------------------------------------
ORG0X04
GOTOINT
;---------------------------------------
bcfINTCON,GIE
BCFINTCON,T0IF;(T0IF)定時(shí)器溢出標(biāo)志位清零
BCFINTCON,T0IE;關(guān)TMR0中斷(T0IE)位清零
BANKSELOPTION_REG
CLRFOPTION_REG
BANKSELHW_TIME
MOVLWHW_TIMECT3
MOVWFHW_TIME
MOVLWHW_TIMECT0
MOVWFTMR0
BANKSELINTCON
BSFINTCON,T0IE
BSFINTCON,GIE
INT;中斷
movwfW_TEMP
movfSTATUS,0
bcfSTATUS,RP0;workinginbank0
movwfSTATUS_TEMP
MOVLWHW_TIMECT0
MOVWFTMR0;重裝定時(shí)常數(shù)
BCFINTCON,T0IF;清除中斷溢出標(biāo)志位(T0IF)
;----------------------------------------------------------------------
DECFSZHW_TIME,1;為零,間跳,定時(shí)時(shí)間到
GOTOHW_LEAVE1
MOVLWHW_TIMECT1;重裝時(shí)間常數(shù)
MOVWFHW_TIME
BSFHW_Sign,1
HW_LEAVE1
BANKSELSTATUS_TEMP
MOVFSTATUS_TEMP,0
MOVWFSTATUS
MOVFW_TEMP
RETFIE
評(píng)論