<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          PIC單片機(jī)外部中斷

          作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
          #INCLUDE"P16F877.inc"
          ORG  000HGOTO A1ORG  04HGOTO ZD01A1   BSF  STATUS,RP0BCF  STATUS,RP1;體1MOVLW 0HMOVWF TRISA;設(shè)置A口為輸出口MOVLW   06H  MOVWF   ADCON1;設(shè)置A口為普通I/O口模式 movlw 0FFHmovwf TRISB;設(shè)定RB為輸入BCF  STATUS,RP0BCF  STATUS,RP1;體0MOVLW 0FFHMOVWF PORTA;A口輸出高電平BCF  INTCON,INTF;清中斷標(biāo)志BSF  INTCON,INTE;開(kāi)外部中斷BSF  INTCON,GIE;開(kāi)總中斷GOTO $ZD01  BTFSS INTCON,INTF;判斷是否發(fā)生外部中斷GOTO ZD02 BCF  INTCON,INTF;清中斷標(biāo)志BTFSS PORTB,0;;判斷觸發(fā)中斷鍵是否抬起避免產(chǎn)生2次中斷GOTO $-1;COMF PORTA,1;取反A口ZD02 RETFIE ;中斷標(biāo)志END#INCLUDE"P16F877.inc"ORG  000HGOTO A1ORG  004H;定時(shí)中斷入口地址 GOTO ZD01;ORG  0CHA1   MOVLW 1;位1顯示數(shù)MOVWF 50H; MOVLW 2;位2顯示數(shù)MOVWF 51H;MOVLW 3;位3顯示數(shù)MOVWF 52H;MOVLW 4;位4顯示數(shù)MOVWF 53H;MOVLW 4;顯示位數(shù)MOVWF 40H;MOVLW B00000001;位碼MOVWF 41H;MOVLW 50H;MOVWF FSR ;間接尋址BSF  STATUS,RP0;選擇體1BCF  STATUS,RP1;MOVLW 00H;1:2TMRO比例MOVWF OPTION_REG;分頻1/2BCF  STATUS,RP0;體0BCF  STATUS,RP1;MOVLW 0FFH;MOVFW TMR0;初值BCF  INTCON,T0IF;清定時(shí)中斷標(biāo)志BSF  INTCON,T0IE;開(kāi)定時(shí)中斷BSF  INTCON,GIE;開(kāi)總中斷A2   BTFSC PORTD,4GOTO A3MOVLW 1MOVWF 50HA3   BTFSC PORTD,5GOTO A4MOVLW 2MOVWF 50HA4   BTFSC PORTD,6GOTO A5MOVLW 3MOVWF 50HA5   BTFSC PORTD,7GOTO A6MOVLW 4MOVWF 50HA6   GOTO A2ZD01  BCF  INTCON,GIE;關(guān)總中斷BTFSS INTCON,T0IF;判斷是否產(chǎn)生定時(shí)中斷GOTO ZD03;否跳出是繼續(xù)執(zhí)行BCF  INTCON,T0IFBSF  STATUS,RP0;體1BCF  STATUS,RP1;MOVLW 0;MOVWF TRISC;RB口設(shè)為輸出口MOVLW B11110000MOVWF TRISD;RD口設(shè)為輸出口BCF  STATUS,RP0;體0BCF  STATUS,RP1;MOVLW 0FFH;MOVWF PORTC;RB口輸出高電平MOVLW 0MOVWF PORTD;RD口輸出低電平起清屏作用MOVFW INDF;間接尋址顯示數(shù)據(jù)  CALL Q1;查數(shù)據(jù)表MOVWF PORTC;顯示斷碼輸出到RB口INCF FSR,1;間接尋址地址加1MOVFW 41H ;位碼MOVWF PORTD;位碼輸出到RD口RLF  41H,0;處理CRLF  41H,1;左移位碼DECFSZ 40H,1;判斷是否顯示完4位GOTO ZD02;否則繼續(xù)顯示MOVLW 4;顯示位數(shù)MOVWF 40H;MOVLW B00000001;位碼MOVWF 41H;MOVLW 50H;MOVWF FSR ;間接尋址ZD02  MOVLW 0FFH;MOVFW TMR0;重裝初值ZD03  BSF  INTCON,GIE;開(kāi)總中斷RETFIE ;中斷返回;********************************************;    數(shù)據(jù)表;********************************************      Q1   ADDWF   PCL,1  RETLW     00C0H        ;0RETLW     00F9H        ;1RETLW     00A4H        ;2RETLW     00B0H        ;3RETLW     0099H        ;4RETLW     0092H        ;5RETLW     0082H        ;6RETLW     00F8H        ;7RETLW     0080H        ;8RETLW     0090H        ;9RETLW     0088H        ;ARETLW     0083H        ;BRETLW     00C6H        ;CRETLW     00A1H        ;DRETLW     0086H        ;ERETLW     008EH        ;FEND 


          關(guān)鍵詞: PIC單片機(jī)外部中

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();