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

;	Adjustable delay with timer0

processor	10F322
include		p10f322.inc

	__CONFIG _WDTE_OFF & _FOSC_INTOSC

i	org	0x40	; General purpose registers start at 0x40

	org	H'00'  	; Reset vector
	goto	setup

	org	H'05'
setup	clrf    ANSELA          ; All ports are digital I/O
	movlw	B'11111011'
	movwf	TRISA		; Port 2 is output
	movlw	B'00000111'	; Fosc/4 and PSA and 1:256
	movwf	OPTION_REG	; Prescaler settings

run	bcf     PORTA, RA2	; Port2 off
	call	delay2
	bsf     PORTA, RA2	; Port2 on
	call	delay2
	goto	run

delay2	movlw	0xf
	movwf	i
l2	call	delay
	decfsz	i,1
	goto	l2
	return

delay	clrf	TMR0
	bcf     INTCON, TMR0IF	; Enable timer1
l1	btfss   INTCON, TMR0IF	; Timer overflow ?
	goto	l1
	return

	end

