; WALK.ASM ; ; To use this program connect four LEDs from each of RB0-RB3 to ground ; via four 470 ohm resistors. The LEDs are illuminated one at time in ; a to-and-fro pattern. ; ; The illumination rate is more or less independent of the PIC clock ; frequency and configuration although this program assumes an RC ; oscillator. The program includes the __CONFIG, __IDLOCS and DE ; directives (mostly just to show how they can be used). The program ; can be used unchanged on any 16X8X device. LIST P=16C84 ERRORLEVEL -302 ;SUPPRESS BANK SELECTION MESSAGES __CONFIG 3FF7H ;RC OSC, WATCHDOG __IDLOCS 1234 ; PORTB EQU 6 TRISB EQU 86H OPTREG EQU 81H STATUS EQU 3 CARRY EQU 0 RP0 EQU 5 MSB EQU 3 ;BIT POSITION OF LEFTMOST LED ; CLRF PORTB ;ALL LEDS OFF BSF STATUS,RP0 ;SELECT REGISTER BANK 1 CLRF TRISB ;SET PORTB TO ALL OUTPUTS MOVLW 0AH MOVWF OPTREG ;ASSIGN PRESCALER (1:4) TO WDT BCF STATUS,RP0 ;SELECT REGISTER BANK 0 INCF PORTB,F ;TURN ON RIGHTMOST LED BCF STATUS,CARRY ;CLEAR CARRY LEFT SLEEP ;WAIT FOR WDT TIMEOUT RLF PORTB,F ;TURN ON LED TO LEFT BTFSS PORTB,MSB ;REACHED LEFTMOST? GOTO LEFT ;LOOP IF NOT RIGHT SLEEP ;WAIT FOR WDT TIMEOUT RRF PORTB,F ;TURN ON LED TO RIGHT BTFSS PORTB,0 ;REACHED RIGHTMOST? GOTO RIGHT ;LOOP IF NOT GOTO LEFT ;START NEW CYCLE ; ORG 2100H ; DE "Copyright (C) 1996 David Tait" END