LIST p=16f628a ;processor 16F628A include "C:\Program Files\MPLAB\P16f628a.inc" ;radix DEC __config 0x3F10 STATUS EQU 0x03 PORTA EQU 0x05 TRISA EQU 0x85 COUNT1 EQU 0x08 COUNT2 EQU 0x09 RP0 EQU 5 RP1 EQU 6 SWPORT EQU 0X05 ;port a SW1 EQU 0x02 ;bit 3, or ra2 cblock 0x20 ;start of general purpose registers count1 ;used in delay routine counta ;used in delay routine countb ;used in delay routine endc org 0x0000 ;org sets the origin, 0x0000 for the 16F628, ;this is where the program starts runninggoto main MOVLW 0x07 ;these two lines are necessary for switch on RA2 to turn off comparitors MOVWF CMCON ;so pin could be used as i/o. Took me 2 hours to figure this out! BSF 0x03,RP0 BCF 0x03,RP1 movlw 0x04 ;these lines set bits 0 and 1 as output and bit 2 as input movwf TRISA ;on port a BCF 0x03,RP0 BCF 0x03,RP1 MAIN MOVLW 0x01 MOVWF PORTA call DELAY BTFSS SWPORT,SW1 ;checks porta, switch 1 and skips next command if set. CALL DELAY MOVLW 0x02 MOVWF PORTA call DELAY BTFSS SWPORT,SW1 CALL DELAY GOTO MAIN DELAY movlw d'250' ;delay 250 ms (4 MHz clock) to make run faster or slower change the d'250' setting movwf count1 d1 movlw 0xC7 movwf counta movlw 0x01 movwf countb Delay_0 decfsz counta, f goto $+2 decfsz countb, f goto Delay_0 decfsz count1 ,f goto d1 retlw 0x00 END