;HAM RADIO CW KEYER WITH THE 87C752

$MOD752

;notes:
;
;DOT paddle is connected to P3.4
;DASH paddle is connected to P3.3
;paddle common is circuit ground
;xmtr is keyed by P3.5 going low
;1KHZ square-wave sidetone is available on P0.4(PWM output) 
;	which can be used to drive base of 2N2222 thru 5K resistor
;	Emiiter goes to ground. Speaker connected between collector
;	and VCC.
;Crystal is 12MHZ.
;A pot is connected with the ends tied between VCC and ground. The
;	wiper is connected to ADC0 (analog channel 0). This pot
;	controls keyer speed.
;

;EQUATES

DOT	EQU	P3.4
DASH	EQU	P3.3
KEY	EQU	P3.5
RESULT	EQU	21H

;CODE STARTS HERE

ORG	000H

INIT:	MOV	PWMP,#17H	;freq= 1 KHZ
	MOV	PWCM,#0FFH	;duty cycle= 0%, i.e.- off for now
	MOV	PWENA,#01H	;turn on pwm output

CHKDOT:	ACALL	RDADC
	JB	DOT,CHKDSH
	CLR	KEY
	MOV	PWCM,#7FH	;turn on pwm
	MOV	B,#02
	ACALL	DELAY
	SETB	KEY
	MOV	PWCM,#0FFH	;turn off pwm
	MOV	B,#02
	ACALL	DELAY
CHKDSH:	JB	DASH,CHKDOT
	CLR	KEY
	MOV	PWCM,#7FH	;turn on pwm
	MOV	B,#6
	ACALL	DELAY
	SETB	KEY
	MOV	PWCM,#0FFH	;turn pwm off	
	MOV	B,#2
	ACALL	DELAY
	SJMP	CHKDOT

DELAY:	MOV	TH,RESULT
	MOV	RTH,RESULT
	MOV	TL,#0
	MOV	RTL,#0
	CLR	TF
	SETB	TR
DL1:	JNB	TF,DL1
	CLR	TF
	DJNZ	B,DL1
	RET

RDADC:	MOV	ADCON,#28H	;START A/D CONVERSION
RDA1:	MOV	A,ADCON
	JNB	ACC.4,RDA1	;WAIT TILL CONVERSION COMPLETE
	MOV	RESULT,ADAT	;READ RESULT
	RET

END
	