;	gpasm -a inhx8m timer2.asm
;	Port 2 ON/OFF
;	DB Henrik Kressner



processor	10F322
include		p10f322.inc

	__CONFIG _WDTE_OFF & _FOSC_INTOSC

	org	H'00'  	; Reset vector
	goto	setup
	org	0x04	; Interrupt vector
	goto	intr

	org	H'05'
setup	clrf    ANSELA          ; Ports 2 are digital I/O
	movlw	B'11111011'
	movwf	TRISA		; Port 2 is output
	movlw	B'11111111'	; 1:16, timer2 og 1:64
	movwf	T2CON		; 
	movlw	B'11000000'	; GEI and PEIE
	movwf	INTCON
	bsf	PIE1, TMR2IE
	bcf	PIR1, TMR2IF

run	goto	run

intr	bcf	PIR1, TMR2IF	; Enable timer2
	btfsc	PORTA, RA2	; What’s on port 2
	goto	off
	goto	on

off	bcf	PORTA, RA2
	RETFIE

on	bsf 	PORTA, RA2
	RETFIE

	end

