mov ACC, i ; PLL 5us,

jz PLL_NOWAIT ; PLL

mov ACC, PLL0CN

jnb ACC.4, PLL_WAIT ; PLL

mov CLKSEL, #022h ; PLL

; 4 P0.0


PLL_NOWAIT:


;----------------------------------------------------------------

;

;----------------------------------------------------------------


; 3

mov SFRPAGE, #001h;


mov TMR3CF, #008h ; 3 SysClk




;----------------------------------------------------------------

;

;----------------------------------------------------------------

mov SFRPAGE, #000h

mov IE, #000h ;

mov IP, #000h ;


;-----------------------------------------------------------------

;

;-----------------------------------------------------------------


; SED1335


ConfigSED1335:

mov R1,#40h ;

lcall WrComm

mov DPTR,#msg1 ;

lcall WrData


mov R1,#44h ;

lcall WrComm

mov dptr,#msg2 ;

lcall WrData


mov r1,#5Dh ;

lcall WrComm

mov dptr,#msg3 ;

lcall WrData


mov r1,#4Ch ;

lcall WrComm


mov R1,#5Ah ;

lcall WrComm

mov DPTR,#msg18 ;

lcall WrData


mov dptr,#5Bh ;

lcall WrComm

mov dptr,#msg4 ;

lcall WrData

mov r1,#59h ;/

lcall WrComm

mov dptr,#msg5;

lcall WrData



Dig_osc:

mov kf,Button_kf

; b2,b1,b0 kf1

mov A, kf

anl A, #007h

mov kf1, A


; b5,b4,b3 kf2

mov A, kf

RR A

RR A

RR A

anl A, #007h

mov kf2, A

mov CoefAmplif,Button_CoefAmplif

mov switch,CoefAmplif


call InputADC1

call Converting


;

mov R1,#46h;

lcall WrComm

mov DPTR,#msg6

lcall WrData

mov R1,#42h;

lcall WrComm

mov DPTR,#00h


M0: movx A, @DPTR ; A XRAM

cjne A, #0A1h, M1 ; ?

ljmp M2


M1:

mov R1, A

clr p3.2 ;a0=0=

mov A, R1 ;

mov P1, A

clr P3.0 ; CS -

clr P3.1 ;

setb P3.1

setb P3.0

inc DPTR

sjmp M0 ;


M2:

sjmp Dig_osc



;


; WrComm


WrComm:

setb P3.2 ; a0=1=

WrComm_1:

mov A, R1 ;

mov P1, A

clr P3.0 ; CS -

clr P3.1 ;

setb P3.1

setb P3.0

ret


Write: clr p3.2 ;a0=0=

sjmp WrComm_1












; WrData

; DPTR .


WrData: clr A

movc A, @A+DPTR ; A ,

cjne A, #0A1h, WrData1; ?

ret


WrData1:

mov R1, A

lcall Write ;

inc DPTR

sjmp WrData ;



;-----------------------------------------------------------------

; 1

;-----------------------------------------------------------------

InputADC1:

mov SFRPAGE, #00Fh


; XRAM 240


cjne kf1,#001h,_5MHz1

;--------------------------

; 10

;--------------------------

_10MHz1:

mov DPTR, #000h ;3

mov ACC, Padc1 ;3

movx @DPTR, A ;3

nop ;1

mov DPTR, #001h

mov ACC, Padc1

movx @DPTR, A

nop

mov DPTR, #002h

mov ACC, Padc1

movx @DPTR, A

nop

; .

; .

; .

mov DPTR, #0EFh

mov ACC, Padc1

movx @DPTR, A

nop


;---------------------------

; 5

;---------------------------

_5MHz1:

cjne kf1, #002h, _2_5MHz1


mov DPTR, #000h

Input1_2:

mov A, Padc1

movx @DPTR, A

inc DPTR

mov A, #0F0h


; 70

nop

nop

nop

nop

nop

nop

nop

cjne A, DPL, Input1_2


;-----------------------------

; 2.5

;-----------------------------

_2_5MHz1:

cjne kf1, #003h, _500KHz1


; c

mov DPTR, #000h

Input1_3:

mov A, Padc1 ;2

movx @DPTR, A

inc DPTR

mov A, #0F0h


; 270

mov i,#008h ;2

djnz i,$ ;3

nop


nop


cjne A, DPL, Input1_3

;-----------------------------

; 500

;-----------------------------

_500KHz1:

cjne kf1, #004h, _250KHz1


; c

mov SFRPAGE, #001h

mov RCAP3H,#0FFh

mov RCAP3L,#05Ch

mov DPTR, #000h

Input1_4:

mov SFRPAGE, #00Fh ;3

mov A, Padc1 ;2

movx @DPTR, A ;3

inc DPTR ;1

mov A, #0F0h ;2

mov SFRPAGE, #001h ;3

mov TMR3CN, #004h ;3


; 1690


jnb TMR3CN.7,$ ;4

nop

nop



mov TMR3CN,#000h ;3

mov TMR3H,#0FFh ;3

mov TMR3L,#05Ch ;3


cjne A, DPL, Input1_4 ;5

;-----------------------------

; 250

;-----------------------------

_250KHz1:

cjne kf1, #005h, _50KHz1


; c

mov SFRPAGE, #001h

mov RCAP3H,#0FEh


mov RCAP3L,#094h

mov DPTR, #000h

Input1_5:

mov SFRPAGE, #00Fh

mov A, Padc1

movx @DPTR, A

inc DPTR

mov A, #0F0h

mov SFRPAGE, #001h

mov TMR3CN, #004h


; 3690


jnb TMR3CN.7,$

nop

nop


mov TMR3CN,#000h

mov TMR3H,#0FEh ;3

mov TMR3L,#094h ;3


cjne A, DPL, Input1_5


;-----------------------------

; 50

;-----------------------------

_50KHz1:

cjne kf1, #006h, _25KHz1


; c

mov SFRPAGE, #001h

mov RCAP3H,#0F8h

mov RCAP3L,#054h


mov DPTR, #000h

Input1_6:

mov SFRPAGE, #00Fh

mov A, Padc1

movx @DPTR, A

inc DPTR

mov A, #0F0h

mov SFRPAGE, #001h

mov TMR3CN, #004h


; 19690

jnb TMR3CN.7,$

nop

nop


mov TMR3CN,#000h

mov TMR3H,#0F8h

mov TMR3L,#054h


cjne A, DPL, Input1_6

;-----------------------------

; 25

;-----------------------------

_25KHz1:

cjne kf1, #007h, _5KHz1


mov SFRPAGE, #001h

mov RCAP3H,#0F0h

mov RCAP3L,#084h


mov DPTR, #000h

Input1_7:

mov SFRPAGE, #00Fh

mov A, Padc1

movx @DPTR, A

inc DPTR

mov A, #0F0h

mov SFRPAGE, #001h

mov TMR3CN, #004h


; 39 690

jnb TMR3CN.7,$

nop

nop

mov TMR3CN,#000h

mov TMR3H,#0F0h

mov TMR3L,#084h

cjne A, DPL, Input1_7

;-----------------------------

; 5

;-----------------------------

_5KHz1:

cjne kf1, #008h, _2_5KHz1


mov SFRPAGE, #001h

: 1, 2, 3, 4, 5, 6