;************************************************************************** ; Input.ASM ; ; This is a simple test of switches ; ; Uses switches connected to RA0 and RA1 to turn LED on or off ; ;************************************************************************** LIST P=16F84, R=DEC __FUSES _XT_OSC & _WDT_OFF & _CP_OFF & _PWRTE_ON include "P16F84.inc" ;-------------------------------------------------------------------------- ; Variables ;-------------------------------------------------------------------------- Ram EQU h'0C' ;-------------------------------------------------------------------------- ; Program Code ;-------------------------------------------------------------------------- ORG 0 ;reset vector Start call Init ;Initialise hardware Loop btfss PORTA, 0 ;Is "ON" button pressed? bsf PORTB, 0 ; Yes - LED on btfss PORTA, 1 ;Is "OFF" button pressed? bcf PORTB, 0 ; Yes - LED off goto Loop ; ;-------------------------------------------------------------------------- ; Subroutines ;-------------------------------------------------------------------------- ;*****Init - set up all ports, make unused ports outputs Init clrf PORTA ;all of porta low clrf PORTB ;all of portb low bsf STATUS, RP0 ;change to bank1 movlw b'00000011' ;all outputs except RA0, 1 movwf TRISA ; movlw b'00000000' ;all outputs movwf TRISB ; bcf STATUS, RP0 ;back to bank0 return END ;Stop assembling here