chastotomer-pic16-asm

//Измеряет частоту импульсов           
            INCLUDE     P16F628A.INC
            __CONFIG    _INTOSC_OSC_NOCLKOUT&_WDT_OFF&_LVP_OFF&_CP_OFF&_PWRTE_ON&_MCLRE_OFF
            ERRORLEVEL  -302
            CBLOCK      20H
            LED3
            LED2
            LED1
            LED0
            ANOD
            W_TEMP
            STATUS_TEMP
            FSR_TEMP
            K
            J
            COUNT
            INDEX
            MEM
            TIMERL
            TIMERM
            ENDC
            ORG         0
            GOTO        START
            ORG         4
            GOTO        INT
START       MOVLW       7
            MOVWF       CMCON
            BSF         STATUS,RP0
            MOVLW       0
            MOVWF       TRISA
            MOVLW       1
            MOVWF       TRISB
            MOVLW       B'11000111'
            MOVWF       OPTION_REG
            BCF         STATUS,RP0
            
            CLRF        INDEX
            CLRF        TIMERL
            CLRF        TIMERM
            CLRF        LED0
            CLRF        LED1
            CLRF        LED2
            CLRF        LED3
            BSF         INTCON,T0IE
            BSF         INTCON,INTE
DISP        BSF         INTCON,GIE
            MOVLW       LED3
            MOVWF       FSR
            MOVLW       1
            MOVWF       ANOD
LOOP        MOVFW       INDF
            CALL        SEGDATA
            MOVWF       PORTB
            MOVFW       ANOD
            MOVWF       PORTA
            CALL        DELAY
            CLRF        PORTA
            INCF        FSR,F
            RLF         ANOD,1
            BTFSS       ANOD,4
            GOTO        LOOP
            GOTO        DISP
SEGDATA                             ;7, 6, 5, 4, 3, 2, 1, 0.
            ADDWF       PCL,F       ;G, F, E, D, C, B, A, PR
;                       АНОД           КАТОД
            RETLW       B'10000001' ; 0 B'01111111'
            RETLW       B'11110011' ; 1 B'00001101'
            RETLW       B'01001001' ; 2 B'10110111'
            RETLW       B'01100001' ; 3 B'10011111'
            RETLW       B'00110011' ; 4 B'11001101'
            RETLW       B'00100101' ; 5 B'11011011'
            RETLW       B'00000101' ; 6 B'11111011'
            RETLW       B'11110001' ; 7 B'00001111'
            RETLW       B'00000001' ; 8 B'11111111'
            RETLW       B'00100001' ; 9 B'11011111'
BIN2BCD     MOVLW       .16
            MOVWF       COUNT
            CLRF        LED0
            CLRF        LED1
            CLRF        LED2
            CLRF        LED3
LOOP8       RLF         TIMERL,F
            RLF         TIMERM,F
            RLF         LED0,F
            RLF         LED1,F
            DECFSZ      COUNT,F
            GOTO        ADJDEC
            
            SWAPF       LED1,W
            ANDLW       0FH
            MOVWF       LED3
            
            MOVFW       LED1
            ANDLW       0FH
            MOVWF       LED2
            
            SWAPF       LED0,W
            ANDLW       0FH
            MOVWF       LED1
            
            MOVFW       LED0
            ANDLW       0FH
            MOVWF       LED0
            RETURN
ADJDEC      MOVLW       LED0
            MOVWF       FSR
            CALL        ADJBCD
            MOVLW       LED1
            MOVWF       FSR
            CALL        ADJBCD
            GOTO        LOOP8
ADJBCD      MOVLW       3
            ADDWF       INDF,W
            MOVWF       MEM
            BTFSC       MEM,3
            MOVWF       INDF
            MOVLW       30
            ADDWF       INDF,W
            MOVWF       MEM
            BTFSC       MEM,7
            MOVWF       INDF
            RETLW       0
DELAY       MOVLW       .4
            MOVWF       J
JLOOP       MOVLW       .255
            MOVWF       K
KLOOP       DECFSZ      K,F
            GOTO        KLOOP
            DECFSZ      J,F
            GOTO        JLOOP
            RETURN                       
INT         
            MOVWF       W_TEMP
            SWAPF       STATUS,W
            MOVWF       STATUS_TEMP
            MOVFW       FSR
            MOVWF       FSR_TEMP
            BCF         INTCON,GIE
            BTFSS       INTCON,INTF
            GOTO        NOINT
            BCF         INTCON,INTF
            
            

            INCF        TIMERL,F
            MOVFW       TIMERL
            XORLW       0
            BTFSC       STATUS,Z
            INCF        TIMERM,F
            
NOINT       BTFSS       INTCON,T0IF
            GOTO        RETINT
            BCF         INTCON,T0IF
            INCF        INDEX,F     
            MOVFW       INDEX
            SUBLW       .15
            BTFSS       STATUS,Z
            GOTO        RETINT
            
NADISP      
            CALL        BIN2BCD
            CLRF        INDEX
            CLRF        TIMERL
            CLRF        TIMERM
            GOTO        RETINT
RETINT      MOVFW       FSR_TEMP
            MOVWF       FSR
            SWAPF       STATUS_TEMP,W
            MOVWF       STATUS
            SWAPF       W_TEMP,F
            SWAPF       W_TEMP,W
            RETFIE
            END

 

НАЗАД                                                                                                                                         ДАЛЕЕ