P2 = 86h.

CRY = 6h - 7

CM = 1 .

CURSOR DIRECTION 4h. CD1 CD2 , .

HORIZONTAL SCROLL RATE ( 5Ah):

P1 = 0 .

OVERLAY ( 5Ah): P1 = 01h.

MX0 = 0 MX1 = 1 - : (L1 and L2) or L3.

DM1 = DM2 = 0 1 3, .

DISPLAY ON/OFF ( 59h) (P1=16h).

. . . , 40 (40*8=320) 240. , , . n 40*n 28h*n.

1 XRAM 000h 0F0h (240 ).

256 , 8 . 240 . . XRAM 0200h 1FFFh.

0 -0.512 , 255 +0.512 . 128 0 . , 000h 0F0h , . ( 5.2).

5.2 .

5.3 - .

46h CSRW - . . .

MWRITE SED1335. 42h .

A. InputADC1, InputADC2 .

.

 

5.3 WrComm WrData

240 , 10 .

 

A

 

.

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

; Ϡ 2006.


; .. 3-11


; FILE NAME : dig_osc.asm

; TARGET MCU : C8051F120

; DESCRIPTION : .

; NOTES : , ,

; ,

;

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



$include (c8051f120.inc)


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

;

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


kf equ R0 ;


; kfn f

; 1 10̠ 100

; 2 5̠ 200

; 3 2.5̠ 400

; 4 500 2

; 5 250 4

; 6 50 20

; 7 25 40

; 8 5ꠠ 200

; 9 2.5 400

;10 500 2

;11 250 4


CoefAmplif equ R2 ;

i equ R3 ; - c1

Num equ R4

kf1 equ R5

kf2 equ R6


switch equ P2 ;,


Button_kf equ P6

Button_CoefAmplif equ P7


Padc1 equ P4 ; 1

Padc2 equ P5 ; 2



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

;

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


cseg AT 0 ; CODE 0

jmp Config ; Config


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

; Main

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


Main segment CODE ; Main, CODE

rseg Main ; Main

using 0 ; 0


Config:

mov SP,#07Fh ; 80h


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

; WDT

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

; WDT

clr EA ;

mov WDTCN, #0DEh

mov WDTCN, #0ADh

setb EA


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

; -

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


mov SFRPAGE, #00Fh ; F SFR


;


mov XBR0, #000h

mov XBR1, #080h ; SYSCKE T2EXE T2E INT1E T1E INT0E T0E CP1E

; 1 0 0 0 0 0 0 0


;/SYSCLK

mov XBR2, #040h ; WEAKPUD XBARE CNVST2E T4EXE T4E UART1E EMIFLE CNVST0E

; 0 1 0 0 0 0 0 0


;

;


;1 - Push-Pull

;0 - Open-Drein


mov P0MDOUT, #03Fh


; -

; P0

;P0.0 = SYSCLK (Push-Pull Output)(Digital)

;P0.1 = GP I/O (Push-Pull Output)(Digital)

;P0.2 = GP I/O (Push-Pull Output)(Digital)

;P0.3 = GP I/O (Push-Pull Output)(Digital)

;P0.4 = GP I/O (Push-Pull Output)(Digital)

;P0.5 = GP I/O (Push-Pull Output)(Digital)

;P0.6 = GP I/O (Open-Drain Output/Input)(Digital)

;P0.7 = GP I/O (Open-Drain Output/Input)(Digital)


mov P1MDOUT, #0FFh

mov P3MDOUT, #0FFh



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

; (SYSCLK=100 P0.6 50 )

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

mov SFRPAGE, #00Fh


mov OSCICN, #083h ;1 ; IOSCEN IFRDY - - - - IFCN1 IFCN0

; 1 0 1 1

;

;

; = 1 (SYSCLK=25 )


mov PLL0CN, #000h ;2 ;PLL

;


mov SFRPAGE, #000h

mov FLSCL, #030h ;3 ; - - FLRT - - - FLWE

; 1 1 0


; Flash

; SYSCLK <= 100 MHz


mov SFRPAGE, #00Fh

mov PLL0CN, #001h ;4 ;PLL

mov PLL0DIV, #001h ;5 ; PLL 1

mov PLL0FLT, #001h ;6 ; , 19-30

;7 ; PLL = 65-100

mov PLL0MUL, #004h ;8 ; PLL 4


; - 5 ;9

mov i, #040h ;

djnz i, $ ;i-- , 0

mov PLL0CN, #003h ;10 ; PLL

mov i, #0FFh ;


PLL_WAIT:


dec i

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

: 1, 2, 3, 4






           

2009 .