
;*******************************
;Name of Program:Blank Template
; date: 
;*******************************

	list	p=12F629
	radix	dec
	include	"p12f629.inc"
	
		errorlevel	-302	; Dont complain about BANK 1 Registers during assembly

	__CONFIG	_MCLRE_OFF & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT  ;Internal osc.

     ;_MCLRE_OFF  - master clear must be off for gp3 to work as input pin 

;******************************
; variables - names and files
;******************************


temp1		equ 20h	
temp2		equ 21h	

;*************************
;Equates
;*************************
status		equ	0x03
rp1			equ	0x06
rp0			equ	0x05
GPIO 		equ 0x05			

status		equ	03h
option_reg	equ 81h

		; bits on GPIO
				
pin7		equ	0	;GP0  
pin6	 	equ	1	;GP1  
pin5		equ	2	;GP2  
pin4		equ	3	;GP3   
pin3		equ	4	;GP4  
pin2		equ	5	;GP5  

		;bits
				
rp0			equ	5	;bit 5 of the status register

;**************************
;Beginning of program
;**************************
		org		0x00
		nop
		nop
		nop
		nop
		nop			
SetUp	bsf		status, rp0 	;Bank 1			
       	movlw	b'11111000'		;Set TRIS  GP0,1,2 out   GP3,4,5 input
		movwf	TRISIO	
		bcf		status, rp0		;bank 0
		movlw   07h         	;turn off Comparator ports
        movwf   CMCON       	;must be placed in bank 0  
		clrf 	GPIO       		;Clear GPIO of junk		
		goto 	Main					

;********************
;* Tables 			*
;********************

table1	addwf   PCL,F   ;02h,1  add W to program counter
		retlw   .10     
		retlw   1ch 
        retlw   0Abh    		
		goto	seq5   		 

;********************
;* Delays 			*
;********************
		
		;5mS delay 
		
_5mS	movlw	05h
		movwf	temp2
_5		nop
		decfsz 	temp1,f
		goto 	_5
		decfsz 	temp2,f
		goto 	_5	
		retlw 	00	

;****************************
;* Sub Routines 			*
;****************************					   
		
		
toggle	movf	count,0
		movwf	temp1
		goto	$+1
		goto	$+1
		decfsz	temp1,1
		goto	$-3
		movlw	b'00000001'
		xorwf	gpio,1		;toggle bit 0	
		retlw	00					
						
;************************************
;* Main 							*
;************************************

Main    clrf	sequences	
		movf	sequences,w
		call	table1
		btfss	gpio,5		;Is swA still pressed?
		goto	$-3			;SwA still pressed		
		movf	sequences,w	;SwA released
		goto	Main					
							
		END
		
		
		