;Example of using Timer1 to generate a 500Hz clock on OC1A

	.DEF	TEMP1=R16	;definitions
	.EQU	KH=$1F		;higher byte of constant
	.EQU	KL=$40		;lower byte of constant

INIT_T1:	
	LDI	TEMP1,$09	;prescaller divide by 1
	OUT	TCCR1B,TEMP1	;and CTC1=1
	LDI	TEMP1,$40	;toggle OC1A
	OUT	TCCR1A,TEMP1	
	LDI	TEMP1,KH	;write higher byte first !!
	OUT	OCR1AH,TEMP1	
	LDI	TEMP1,KL	
	OUT	OCR1AL,TEMP1	
	LDI	TEMP1,$40	;clear flag
	OUT	TIFR,TEMP1	
	OUT	TIMSK,TEMP1	;and enable interrupt
	RET		
