频率很高的,以下是程序:
W0 EQU 30H
W1 EQU 31H
W2 EQU 32H
W3 EQU 33H
W4 EQU 34H
ZLG_BIT_CNT EQU 35H ;The number of count bit
ZLG_DECIMAL EQU 36H ;The digit of decimal
ZLG_DELAY EQU 37H ;The variable for delay function
ZLG_REC_BUF EQU 38H ;The buffer of data sended
ZLG_SEND_BUF EQU 39H ;The buffer of data received
;=========================================
ADC9850_FQOD EQU P3.0
ADC9850_WCLK EQU P3.1
LCD_CS EQU P1.7 ;/CS of LCD
LCD_SID EQU P1.6 ;SID of LCD
LCD_SCLK EQU P1.5 ;CLK of LCD
;=========================================
ORG 0000H
AJMP MAIN
ORG 0030H
;=========================================
MAIN:
;LCALL LCD_INITIALIZE
LCALL ADC9850_INITIALIZE
MAIN_LOOP:
;LCALL KEY
;LCALL LCD_DISPLAY
;LCALL AD9850_NUM_CHANGE
LCALL ADC9850_CHANGE
JMP $
RET
;=========================================
LCD_INITIALIZE:
LCALL DELAY
LCALL DELAY
LCALL DELAY
MOV A,#00000001B ;CLEAR DISPLAY
LCALL LCD_WRITE_COMM
MOV A,#00110000B ;FUNCTION SETTING
LCALL LCD_WRITE_COMM
MOV A,#00000010B ;DDRAM SET TO '00H'
LCALL LCD_WRITE_COMM
MOV A,#00000110B ;
LCALL LCD_WRITE_COMM
MOV A,#00001100B ;DISPLAY ON
LCALL LCD_WRITE_COMM
MOV A,#00000001B ;CLEARING SCREEN
LCALL LCD_WRITE_COMM
MOV A,#10000000B ;SET DDRAM ADDRESS
LCALL LCD_WRITE_COMM
RET
;=========================================
ADC9850_INITIALIZE:
LCALL DELAY
SETB ADC9850_FQOD
SETB ADC9850_WCLK
MOV P1,#0FFH
MOV W0,#40H
MOV W1,#00H
MOV W2,#30H
MOV W3,#7FH
MOV W4,#24H
LCALL DELAY
RET
;==========================================
/*use of display number
translate into 32 bit
frequency control char
*/
ADC9850_NUM_CHANGE:
RET
;===========================================
/*
ZLG_7289 KEY
*/
/*
KEY:
JNB ZLG_KEY,KEY_SEARCH
AJMP K1
KEY_SEARCH:
MOV ZLG_SEND_BUF,#00010101B
LCALL ZLG_SEND
LCALL ZLG_RECEIVE;
SETB ZLG_CS
MOV A,ZLG_REC_BUF
KEY0:
CJNE A,#00H,KEY1
LCALL KEY0_TURN_ON_TIME
KEY1
CJNE A,#01H,WAIT_EXIT
CALL KEY2_CLEAR
WAIT_EXIT:
JNB ZLG_KEY,WAIT_EXIT
RET
*/
;===========================================
/*
use of display dac9850
output frequency
*/
LCD_DISPLAY:
RET
;===========================================
ADC9850_CHANGE:
CLR ADC9850_FQOD
/*
SEND W0(include phasi
c control char and power
supply control char(0) and
work way control char(00)
*/
MOV A,W0
MOV P1,A
SETB ADC9850_WCLK
NOP
NOP
CLR ADC9850_WCLK
/*
send w0~w4 (32 bit frequency
control char)
*/
MOV A,W1
MOV P1,A
SETB ADC9850_WCLK ;ascend in effect
NOP
NOP
CLR ADC9850_WCLK
MOV A,W2
MOV P1,A
SETB ADC9850_WCLK
NOP
NOP
CLR ADC9850_WCLK
MOV A,W3
MOV P1,A
SETB ADC9850_WCLK
NOP
NOP
CLR ADC9850_WCLK
MOV A,W4
MOV P1,A
SETB ADC9850_WCLK
NOP
NOP
CLR ADC9850_WCLK
NOP
NOP
SETB ADC9850_FQOD
RET
;==========================================
LCD_WRITE_COMM:
LCALL DELAY1 ;INSTEAD OF CHECKING BF STATE
SETB LCD_CS
PUSH ACC
MOV R0,#08H
MOV A,#11111000B
COMM1:
CLR C
RLC A
CLR LCD_SCLK
MOV LCD_SID,c
SETB LCD_SCLK
DJNZ R0,COMM1
POP ACC
PUSH ACC
ANL A,#0F0H
MOV R0,#8
COMM2:
CLR C
RLC A
CLR LCD_SCLK
MOV LCD_SID,C
SETB LCD_SCLK
DJNZ R0,COMM2
POP ACC
SWAP A
ANL A,#0F0H
MOV R0,#08H
COMM3:
CLR C
RLC A
CLR LCD_SCLK
MOV LCD_SID,C
SETB LCD_SCLK
DJNZ R0,COMM3
CLR LCD_CS
RET
;===================================================================
LCD_WRITE_DATA:
LCALL DELAY1 ;INSTEAD OF CHECKING BF STATE
PUSH ACC
SETB LCD_CS ;Enable lcd
MOV R0,#08H
MOV A,#11111010B
DATA1:
CLR C
RLC A
CLR LCD_SCLK
MOV LCD_SID,C
SETB LCD_SCLK
DJNZ R0,DATA1
POP ACC
PUSH ACC
ANL A,#0F0H
MOV R0,#8
DATA2:
CLR C
RLC A
CLR LCD_SCLK
MOV LCD_SID,C
SETB LCD_SCLK
DJNZ R0,DATA2
POP ACC
PUSH ACC
SWAP A
ANL A,#0F0H
MOV R0,#8
DATA3:
CLR C
RLC A
CLR LCD_SCLK
MOV LCD_SID,C
SETB LCD_SCLK
DJNZ R0,DATA3
CLR LCD_CS
POP ACC
RET
;==========================================
DELAY:
MOV R1,#00H
DD1:
MOV R2,#00H
DJNZ R2,$
DJNZ R1,DD1
RET
DELAY1:
MOV R7,#010H
D11: MOV R6,#010H
DJNZ R6,$
DJNZ R7,D11
RET
;==========================================
END
用户427386 2012-8-13 12:07