; TUTA4.ASM ; using aliases, bit names and conditional loops list p=p16f877 radix hex include "p16f877.inc" __CONFIG _HS_OSC & _WDT_OFF & _LVP_OFF ; high speed >4MHz OSC ; disable watchdog timer #DEFINE PAGE0 BCF STATUS,5 #DEFINE PAGE1 BSF STATUS,5 COUNT EQU 0x20 ; Counter storage NCOUNT EQU 0x21 ; Count Down storage register MCOUNT EQU 0x22 ; Count Down storage register OCOUNT EQU 0x23 ; Count Down storage register SHIFT EQU 0x24 ; Temporary pattern register W EQU 0 ; Working register flag F EQU 1 ; File register flag C EQU 0 ; Carry flag ORG 0 ; Reset vector CALL 5 ; CALL start of program ORG 4 ; Interrupt vector CALL 5 ; CALL start of program ORG 5 ; Start of program memory CLRF PORTA ; clear Port A data register CLRF PORTB ; clear Port B data register CLRF PORTC ; clear Port C data register CLRF PORTD ; clear Port D data register CLRF PORTE ; clear Port E data register PAGE1 ; PAGE1 CLRF TRISA ; set all Port A as output (clear direction reg) CLRF TRISB ; set all Port B as output (clear direction reg) CLRF TRISC ; set all Port C as output (clear direction reg) CLRF TRISD ; set all Port D as output (clear direction reg) CLRF TRISE ; set all Port E as output (clear direction reg) PAGE0 ; PAGE0 BCF STATUS,C ; disable carry flag MOVLW B'00000001' ; initial bit pattern MOVWF SHIFT ; store pattern ; ; This will cause my pants to sequence through the active ; ports B,C,D. These ports were specifically choosen, and ; the wires run in such a way to make the programming ; ridiculously easy. Simply rotating a bit. ; SEQALL MOVF SHIFT,W ; retreive latest bit pattern MOVWF PORTB ; turn on a yellow wire CALL PAUSE ; approx. 1 second delay CLRF PORTB ; clean up glowing wire MOVF SHIFT,W ; retreive latest bit pattern MOVWF PORTC ; turn on a red wire CALL PAUSE ; approx. 2 second delay CLRF PORTC ; clean up glowing wire MOVF SHIFT,W ; retreive latest bit pattern MOVWF PORTD ; turn on a blue wire CALL PAUSE ; approx. 1 second delay CLRF PORTD ; clean up glowing wire RLF SHIFT,F ; move onto next wire all colors GOTO SEQALL ; again, next bit ; ; Delay ; PAUSE MOVLW 0xFF MOVWF MCOUNT LOADN MOVLW 0xFF MOVWF NCOUNT DECO NOP NOP DECFSZ OCOUNT,F GOTO DECO DECFSZ MCOUNT,F GOTO LOADN RETURN END