Понедельник, Май 25, 2020

0,1,2,3,4,5,6,7,8,9 PIC ASM

;Теперь зделаем так,чтобы везде высвечивалось 0 затем 1 и так до 9-ки.            
            LIST        P=16F628A
            INCLUDE     P16F628A.INC
            __CONFIG    _INTOSC_OSC_NOCLKOUT&_WDT_OFF&_PWRTE_ON&_MCLRE_OFF&_LVP_OFF
            ERRORLEVEL  -302
            CBLOCK      20H
            W_TEMP
            STATUS_TEMP
            J
            K
            ENDC
BANK0       MACRO
            BCF         STATUS,RP0
            BCF         STATUS,RP1
            ENDM
BANK1       MACRO
            BSF         STATUS,RP0
            BCF         STATUS,RP1
            ENDM
            ORG         0
            GOTO        START
            ORG         4
            GOTO        ISR
START       MOVLW       7
            MOVWF       CMCON

            CLRF        PORTB
            CLRF        PORTA
            BANK1
            MOVLW       B'11110000'
            MOVWF       TRISA
            MOVLW       B'00000001'
            MOVWF       TRISB
            BANK0
;Подаём напряжение на общий Катод
            MOVLW       B'00001111'
            MOVWF       PORTA
;Записываем в порт Б 0
MAIN        MOVLW       B'10000000'
            MOVWF       PORTB
            CALL        DELAY
;1
            MOVLW       B'11110010'
            MOVWF       PORTB
            CALL        DELAY
;2            
            MOVLW       B'01001000'
            MOVWF       PORTB
            CALL        DELAY
;3           
            MOVLW       B'01100000'
            MOVWF       PORTB
            CALL        DELAY
;4            
            MOVLW       B'00110010'
            MOVWF       PORTB
            CALL        DELAY
;5            
            MOVLW       B'00100100'
            MOVWF       PORTB
            CALL        DELAY
;6           
            MOVLW       B'00000100'
            MOVWF       PORTB
            CALL        DELAY
;7            
            MOVLW       B'11110000'
            MOVWF       PORTB
            CALL        DELAY
;8            
            MOVLW       B'00000000'
            MOVWF       PORTB
            CALL        DELAY
;9            
            MOVLW       B'00100000'
            MOVWF       PORTB
            CALL        DELAY
            
            GOTO        MAIN
;Функция задержки
DELAY       MOVLW       .255
            MOVWF       J
JLOOP       MOVLW       .255
            MOVWF       K
KLOOP       DECFSZ      K,F
            GOTO        KLOOP
            DECFSZ      J,F
            GOTO        JLOOP
            RETURN
            
ISR         MOVWF       W_TEMP
            SWAPF       STATUS,W
            BCF         STATUS,RP0
            MOVWF       STATUS_TEMP   
                     
EXIT_ISR    SWAPF       STATUS_TEMP,W
            MOVWF       STATUS
            SWAPF       W_TEMP,F
            SWAPF       W_TEMP,W
            RETFIE
            END



НАЗАД                                        Cи ATtiny2313                                   ASSEMBLER ATtiny2313                             ДАЛЕЕ


Back to Top