您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机pic16f84 LED频率计 正文
pic16f84 LED频率计

pic16f84 LED频率计

点击数:7751 次   录入时间:03-04 11:38:25   整理:http://www.55dianzi.com   PIC单片机
            MOVlw      b’00011000’ ; RA0..RA2 output, RA3, RA4 input
            MOVwf      TRISA
            bcf        STATUS,RP0

;+-----------------------------------------------------------------------+
;| 7-step cycle of digits                                                |
;+-----------------------------------------------------------------------+

LEDCycle    MOVlw      LED0
            addwf      LEDIndex,W  ; LED1 + LEDIndex -> W

            MOVwf      FSR         ; W -> FSR
            MOVf       INDF,W      ; LED(0..6) -> W
            call       LEDTable    ; W contains segments

            MOVwf      Temp        ; test for decimal point
            MOVlw      5

            bsf        STATUS,Z
            subwf      LEDIndex,W
            btfss      STATUS,Z
            goto       NoDot
            bsf        Temp,7      ; common cathode....
;           bcf        Temp,7      ; common anode....

NoDot       MOVf       Temp,W
            MOVwf      PORTB       ; segments -> PORTB

            MOVf       LEDIndex,W  ; LEDIndex -> W
            nop
            MOVwf      PORTA       ; digit number -> PORTA

;+------------------------------------------------------------------------
;Test for TMR0 overflow
;+------------------------------------------------------------------------

            btfss      INTCON,2    ; Test for TMR0 overflow
            goto       DoNothing
            incf       TimerH,F    ; YES! Increment SW counter
            bcf        INTCON,2    ; clear overflow bite
            goto       O_K

DoNothing   nop
            nop
            nop

;+-----------------------------------------------------------------------+
;| The first timing loop 2+3*T1 procesor cycles                          |
;+-----------------------------------------------------------------------+

O_K         MOVlw      T1
            MOVwf      Temp

Pause       decfsz     Temp,F
            goto       Pause
            nop

;+-----------------------------------------------------------------------+
;| The end of one digit processing                                       |
;+-----------------------------------------------------------------------+

            incf       LEDIndex,F
            MOVlw      7           ; is 7th?
            bcf        STATUS,Z
            subwf      LEDIndex,W
            btfss      STATUS,Z
            goto       LEDCycle    ; next digit
            nop

;+-----------------------------------------------------------------------+
;| The second timing loop 2+3*T2 procesor cycles                         |

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]  下一页


本文关键字:暂无联系方式PIC单片机单片机-工控设备 - PIC单片机