;Алгоритм сканирования кнопок на одном порте.Нажимая кнопки будет загораться светодиод.
LIST P=16F628A
INCLUDE P16F628A.INC
__CONFIG _INTOSC_OSC_NOCLKOUT&_WDT_OFF&_PWRTE_ON&_MCLRE_OFF&_LVP_OFF
ERRORLEVEL -302
CBLOCK 20H
J
K
COUNT
TEMP
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
BANK1
MOVLW B'11110111'
MOVWF TRISB
MOVLW .255
MOVWF TRISA
BANK0
MAIN CLRF PORTB
CLRF COUNT
MOVF PORTA,W
MOVWF TEMP
TEST RRF TEMP,F
BTFSS STATUS,C
GOTO PROC
INCF COUNT,F
MOVLW 7
SUBWF COUNT,W
BTFSS STATUS,Z
GOTO TEST
GOTO MAIN
PROC MOVLW B'00001000'
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
RETFIE
END
НАЗАД Assembler AVR Си AVR ДАЛЬШЕ