home *** CD-ROM | disk | FTP | other *** search
- ;This program runs on the PICDBD-1 demo board.
- ;In the Demo board, Port B is connected to 8 LEDs.
- ;RA1 is connected to a switch (S3). This program increments
- ;the file register count each time S3 is pressed.
- ;The value of count is displayed on the LEDs connected
- ;to Port B.
- ;Net result is that Leds should increment in a binary
- ;manner every time S3 is pressed.
-
- list p=16F84, f=inhx8m
- ;
- ;Define addresses of registers
- ;
- STATUS equ 03h
- PORTA equ 05h
- TRISA equ 05h
- PORTB equ 06h
- TRISB equ 06h
- ;
- ;Define bit positions in registers
- ;
- RP0 equ 5
- ;
- ;Define RAM locations
- ;
- COUNT equ 0Ch
- ;
- ;
- org 00h ;reset vector.
- goto Start
-
- org 05h
-
- Start bsf STATUS,RP0 ;Select bank 1
- movlw b'00000000' ;Initialise Port B - all outputs
- movwf TRISB
- movlw b'11111111' ;Initialise Port A - all inputs
- movwf TRISA
- bcf STATUS,RP0 ;Select bank 0
- clrf COUNT ;clear count
-
- Loop btfss PORTA,1 ;see if RA1 pressed
- goto IncCnt ;yes then inc count
- EndLoop goto Loop ;else check again
-
- IncCnt incf COUNT ;inc count
- movf COUNT,w ;
- movwf PORTB ;display on port b
-
- Release btfss PORTA,1 ;wait for key release
- goto Release ;not release then wait
- EndRel goto Loop ;else check key press again
- ;
- end
-
-
-