; TB31213FN  PLL201  Ver.1.01 (1ch binary control version)
;;----------------------------------------------------------
; PIC16F84 Portmap
; RA1	CK
; RA2	D
; RA3	STB
; OSC is XT.  WDT is disable.  PLL-OSC=12.8MHz
        LIST    p=16F84 ; PIC16F84 is the target processor
;----- To TB31213FN -----
STATUS	EQU	03H
RP0	EQU	05H
TRISA	EQU	85H
TRISB	EQU	86H
PORTA	EQU	05H
PORTB	EQU	06H
;------ Reg. Map --------
LPC	EQU	0CH
DR1	EQU	12H
;----- Defined Freq -----
; ex. 321.00MHz -->07D64H (10KHz/STEP)
CH1H	EQU	21H	;周波数データ用レジスタ---MSB
CH1M	EQU	22H	;周波数データ用レジスタ
CH1L	EQU	23H	;周波数データ用レジスタ---LSB
;------------------ MAIN PROG. --------------------------
	ORG	0
MAIN	CALL	INIT
	CALL	RFDINIT
	MOVLW	000H	;******** 周波数データ指定---MSB(00) **********
	MOVWF	CH1H
	MOVLW	07DH	;******** 周波数データ指定------(7D) **********
	MOVWF	CH1M
	MOVLW	064H	;******** 周波数データ指定---LSB(64) **********
	MOVWF	CH1L
	CALL	OUTFQ
SLP	NOP
	SLEEP
	GOTO	MAIN
;-------------------------------------------------------
OUTFQ	NOP
	MOVF	CH1L,0		;-----
	MOVWF	DR1
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	MOVF	CH1M,0		;-----
	MOVWF	DR1
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	CALL	SFTDT
	MOVF	CH1H,0		;-----
	MOVWF	DR1
	CALL	SFTDT
	CALL	H_OUT		;-----
	CALL	L_OUT
	CALL	STBOUT
	RETURN
;------------------------
SFTDT	NOP
	BTFSC	DR1,0
	GOTO	SFTDT1
	CALL	L_OUT
	GOTO	SFTDT2
SFTDT1	CALL	H_OUT
SFTDT2	RRF	DR1,1
	RETURN
;------------------------
;REF DEVIDEr OSC=12.8MHz STEP=10KHz REFDEV=D'1280'=0101,0000,0000,
;------------------------
RFDINIT	CALL	L_OUT	;D0	LSB	;0　リファレンスカウンタ　セット
	CALL	L_OUT	;D1		;0　 N=1280(0500H)---10KHz STEP
	CALL	L_OUT	;D2		;0
	CALL	L_OUT	;D3		;0
	CALL	L_OUT	;D4		;0
	CALL	L_OUT	;D5		;0
	CALL	L_OUT	;D6		;0
	CALL	L_OUT	;D7		;0
	CALL	H_OUT	;D8		;1
	CALL	L_OUT	;D9		;0
	CALL	H_OUT	;D10		;1
	CALL	L_OUT	;D11	MSB	;0
	CALL	H_OUT	;group CoDE	;1
	CALL	H_OUT	;B'11'iS rEFDEv	;1
	CALL	STBOUT
; OPTION REG. INIT
	CALL	L_OUT	;T1
	CALL	L_OUT	;T2
	CALL	L_OUT	;T3
	CALL	L_OUT	;CpT1
	CALL	L_OUT	;CpT2
	CALL	L_OUT	;Cpr1
	CALL	L_OUT	;Cpr2
	CALL	L_OUT	;lD1
	CALL	L_OUT	;lD2
	CALL	L_OUT	;Tx
	CALL	H_OUT	;rx
	CALL	L_OUT	;group CoDE
	CALL	L_OUT	;B'00' iS opTion rEg.
	CALL	STBOUT
	RETURN
;------------------------
L_OUT	BCF	PORTA,2
	CALL	OUTP
	RETURN
H_OUT	BSF	PORTA,2
	CALL	OUTP
	RETURN
OUTP	NOP
	BSF	PORTA,1
	BCF	PORTA,1
	RETURN
STBOUT	NOP
	BSF	PORTA,3
	BCF	PORTA,3
	RETURN
;------------------------
INIT	BSF	STATUS,RP0
	MOVLW	b'00010001'
	MOVWF	TRISA
	MOVLW	b'11111111'
	MOVWF	TRISB
	BCF	STATUS,RP0
	MOVLW	0
	MOVWF	PORTA
	RETURN
;------------------------
	END
