 |
;***********************************************************
; step06 for PIC16F84A
; step06.asm, H. OSADA, Nov. 2024
;***********************************************************
;
;=================================================
; definitions
;=================================================
;- hardware -----------------------------------
LIST P=PIC16F84A
#INCLUDE "P16F84A.INC"
;
__CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON
& _CP_OFF
;
;- constant label -----------------------------
SW1 EQU 003H ;RA3
SW2 EQU 004H ;RA4
LED1 EQU 000H ;RB0
LED2 EQU 001H ;RB1
;
;- file register ------------------------------
CBLOCK 0CH
counter
ENDC
;
;=================================================
; run start
;=================================================
;- reset start --------------------------------
ORG 0
GOTO INIT
;
;- interrupt start ----------------------------
ORG 4
GOTO ISR
;
;- initialize ---------------------------------
INIT
BSF STATUS,RP0
;Bank0->Bank1
MOVLW 018H
MOVWF TRISA
CLRF TRISB
BCF STATUS,RP0 ;Bank1->Bank0
;
BSF PORTB,LED1
BSF PORTB,LED2
CLRF counter
;
;=================================================
; main routine
;=================================================
MAIN
INCF counter,F
;
BTFSS PORTA,SW1
GOTO LED1_ON
GOTO LED1_OFF
LED1_ON
BTFSS counter,0
GOTO LED1_OFF
BCF PORTB,LED1
GOTO LED1_END
LED1_OFF
BSF PORTB,LED1
LED1_END
;
BTFSS PORTA,SW2
GOTO LED2_ON
GOTO LED2_OFF
LED2_ON
BTFSC counter,0
GOTO LED2_OFF
BCF PORTB,LED2
GOTO LED2_END
LED2_OFF
BSF PORTB,LED2
LED2_END
GOTO MAIN
;
;=================================================
; interrupt service routine
;=================================================
ISR
;** procedure
;
;=================================================
; subroutine
;=================================================
;** procedure
;
;***********************************************************
END |