新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PIC16F877A單片機(jī)led的動(dòng)態(tài)顯示

        PIC16F877A單片機(jī)led的動(dòng)態(tài)顯示

        作者: 時(shí)間:2011-02-24 來源:網(wǎng)絡(luò) 收藏

        list p=16F877A,R=DEC
        include "p16F877A.inc"
        ;;;;;user variables;;;;;;;;
        Count2 equ 23H
        Count3 equ 24H
        data_out1 equ 25H
        data_out2 equ 26H
        ;;;;;;;reset vector;;;;;;;;;
        org 0x00
        goto mainline
        ;;;;;;delay program;;;;;;;
        delay_2ms
        movlw 0x05
        movwf Count2
        lp0 movlw 0xff
        movwf Count3
        lp1 decfsz Count3,F
        goto lp1
        decfsz Count2,F
        goto lp0
        return

        delay_250ms
        movlw 0x41
        movwf Count2
        movlw 0xff
        movwf Count3
        decfsz Count3,F
        goto $-1
        decfsz Count2,F
        goto $-5
        movlw 0xff
        movwf Count2
        movlw 0xff
        movwf Count3
        decfsz Count3,F
        goto $-1
        decfsz Count2,F
        goto $-5
        return
        ;;;;;;main program;;;;;;;;;
        mainline
        banksel TRISA
        movlw 0x00
        movwf TRISA
        movlw 0xff
        movwf TRISB
        movlw 0x00
        movwf TRISC
        movwf TRISD
        movwf TRISE

        banksel PORTA
        movlw 0x00
        movwf PORTA
        movwf PORTB
        movwf PORTC
        movwf PORTD
        movwf PORTE

        banksel INTCON
        bcf INTCON,PEIE
        lp
        btfsc PORTB,0
        goto lp
        call delay_250ms
        wait1
        btfss PORTB,2
        goto led1
        btfss PORTB,3
        goto led2
        goto wait1
        lp2
        movf PORTA,W
        movwf data_out1
        L2
        btfsc PORTB,1
        goto L2
        call delay_250ms
        wait2
        btfss PORTB,2
        goto led3
        btfss PORTB,3
        goto led4
        goto wait2
        led1
        call delay_250ms
        movlw 0x00
        movwf PORTA
        movlw 0x01
        movwf PORTA
        movlw 0xfe
        movwf PORTC
        goto lp2
        led2
        call delay_250ms
        movlw 0x00
        movwf PORTA
        movlw 0x02
        movwf PORTA
        movlw 0xfe
        movwf PORTC
        goto lp2
        led3
        call delay_250ms

        movlw 0x01
        movwf PORTA
        movlw 0xfd
        movwf PORTC
        call delay_2ms

        banksel PORTC
        movlw 0x00
        movwf PORTC
        movlw 0xfe
        movwf PORTC
        movf data_out1,W
        movwf PORTA

        call delay_2ms
        call delay_2ms

        led4
        call delay_250ms

        movlw 0x02
        movwf PORTA
        movlw 0xfd
        movwf PORTC
        call delay_2ms

        banksel PORTC
        movlw 0x00
        movwf PORTC
        movlw 0xfe
        movwf PORTC
        movf data_out1,W
        movwf PORTA

        call delay_2ms

        end



        評(píng)論


        相關(guān)推薦

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

        關(guān)閉
        主站蜘蛛池模板: 内黄县| 漠河县| 修水县| 本溪市| 南京市| 宕昌县| 平舆县| 株洲市| 陕西省| 将乐县| 内黄县| 新化县| 大化| 曲周县| 娱乐| 霍城县| 海淀区| 浑源县| 南部县| 正定县| 乳源| 安多县| 元阳县| 望江县| 黑山县| 新津县| 咸丰县| 灯塔市| 三门峡市| 庐江县| 阳山县| 五河县| 乌苏市| 长子县| 沂南县| 工布江达县| 江永县| 日土县| 乐东| 武清区| 克什克腾旗|