;************************************************************* ;FLASHING LEDs! ;This program continuously outputs a series of led patterns, ;using pingpong hardware. ;TJW 5.3.05 Tested in simulation 11.3.05 ;************************************************************* ;Clock is 1MHz ;Configuration Word: WDT off, power-up timer on, ; code protect off, RC oscillator ; list p=16F84A ; ;specify SFRs pcl equ 02 status equ 03 porta equ 05 trisa equ 05 portb equ 06 trisb equ 06 ; pointer equ 10 delcntr1 equ 11 delcntr2 equ 12 ; org 00 ;Initialise start bsf status,5 ;select memory bank 1 movlw B'00011000' movwf trisa ;port A according to above pattern movlw 00 movwf trisb ;all port B bits output bcf status,5 ;select bank 0 ; ;The “main” program starts here movlw 00 ;clear all bits in port A movwf porta movwf pointer ;also clear pointer loop movf pointer,0 ;move pointer to W register call table movwf portb ;move W register, updated from table SR, to port B call delay incf pointer,1 btfss pointer,3 ;test if pointer has incremented to 8 goto loop ;if not, just loop again ;here if pointer needs to be cleared movlw 00 movwf pointer ;clear pointer to start over goto loop ; ;************************************************************* ;Subroutines ;************************************************************* ;Introduces delay of 500ms approx, for 1 MHz clock delay movlw D'100' movwf delcntr2 outer movlw D'250' ; movwf delcntr1 inner nop nop decfsz delcntr1,1 goto inner decfsz delcntr2,1 goto outer return ;Holds Lookup Table table addwf pcl,1 retlw 23 retlw 3f retlw 47 retlw 7f retlw 0a2 retlw 1f retlw 03 retlw 67 ; end