📄 dds.lst
字号:
C51 COMPILER V7.20 DDS 07/30/2005 16:03:15 PAGE 1
C51 COMPILER V7.20, COMPILATION OF MODULE DDS
OBJECT MODULE PLACED IN DDS.OBJ
COMPILER INVOKED BY: D:\Program\C51\BIN\C51.EXE DDS.c DEBUG OBJECTEXTEND
line level source
1 //--------------------------------头文件
2 #include<reg52.h>
3 #include <stdlib.h>
4 //----------------------------------自定义
5 #define ulong unsigned long
6 #define uint unsigned int
7 #define uchar unsigned char
8 #define send_fpga P0
9 #define key_port P1
10 #define control P2
11 sbit cp=P2^0;
12 sbit ad=P2^1;
13 sbit db7=P2^2;
14 sbit en=P3^5;
15 sbit rw=P3^6;
16 sbit rs=P3^7;
17 bit fre_mode=0; //1在频率模式下
18 bit ran_mode=0; //1在幅度模式下
19 bit mut_mode=0; //1在调相模式下
20 bit no_data=0; //0表示没有输入数据
21 uchar keycode; //键值
22 uchar scancode;
23 uchar wave_one_data=0; //第一路波形控制,0表Sine
24 uchar wave_two_data=0; //第二路波形控制,0表Sine
25 uchar road_mode=1; //1表第一路
26 uchar line[8]; //连接字字符
27 uchar p=0; //连字符指针
28 //----------------------
29 void da_clr(void)
30 { uchar i;
31 1 for (i=0;i<8;i++)
32 1 {line[i]=0;}
33 1 }
34 //----------------------------------串行输入并行输出数据
35 void da_out(uchar num)
36 {
37 1 uchar i;
38 1 for(i=8;i>0;i--)
39 1 {
40 2 CY=0;
41 2 num<<=1;
42 2 ad=CY;
43 2 cp=0;
44 2 cp=1;
45 2 }
46 1 }
47 //--------------------------------------忙信号延时
48 void busy_delay(void)
49 { uchar i = 20;
50 1 while(i--);
51 1 }
52 //-----------------------------写指令
53 void write_inst(uchar x)
54 {
55 1 da_out(x);
C51 COMPILER V7.20 DDS 07/30/2005 16:03:15 PAGE 2
56 1 busy_delay();
57 1 rs=0;
58 1 rw=0;
59 1 en=1;
60 1 en=0;
61 1 }
62 //-----------------------------写数据
63 void write_data(void)
64 {
65 1 da_out(ACC);
66 1 busy_delay();
67 1 rs=1;
68 1 rw=0;
69 1 en=1;
70 1 en=0;
71 1 }
72 //--------------------------------清屏
73 void cls(void)
74 {
75 1 write_inst(0x01);
76 1 }
77 //---------------------------------重新定义显示方式
78 void initial(void)
79 {
80 1 write_inst(0x38); //用8位传输数据,显示用5*7
81 1 write_inst(0x0e); //显示器显示,光标显示并闪烁
82 1 write_inst(0x06); //每次输入,光标向右移动一格
83 1 }
84 //---------------------------------------查表输入菜单数据
85 void lcd_show( uchar *see )
86 {
87 1 while(*see)
88 1 {
89 2 ACC=*see++;
90 2 write_data();
91 2 }
92 1 }
93 //---------------------------------------显示菜单
94 void t_first(void)
95 {cls();
96 1 write_inst(0x80); lcd_show(" The ");
97 1 write_inst(0xc0); lcd_show(" first road ");
98 1 }
99 //-------------------------------------
100 void t_second(void)
101 {cls();
102 1 write_inst(0x80); lcd_show(" The ");
103 1 write_inst(0xc0); lcd_show(" second road ");
104 1 }
105 //-------------------------------------------
106 void sine_wave(void)
107 {cls();
108 1 write_inst(0x80); lcd_show(" choose the way ");
109 1 write_inst(0xc0); lcd_show(" Sine wave ");
110 1 }
111 //-------------------------------------
112 void square_wave(void)
113 {cls();
114 1 write_inst(0x80); lcd_show(" choose the way ");
115 1 write_inst(0xc0); lcd_show(" Square wave ");
116 1 }
117 //-----------------------------------------
C51 COMPILER V7.20 DDS 07/30/2005 16:03:15 PAGE 3
118 void triangle_wave(void)
119 {cls();
120 1 write_inst(0x80); lcd_show(" choose the way ");
121 1 write_inst(0xc0); lcd_show(" Triangle wave ");
122 1 }
123 //-----------------------------------
124 void teeth_wave(void)
125 {cls();
126 1 write_inst(0x80); lcd_show(" choose the way ");
127 1 write_inst(0xc0); lcd_show(" Teeth wave ");
128 1 }
129 //-----------------------------------
130 void fre_port(void)
131 {cls();
132 1 write_inst(0x80); lcd_show("importation data");
133 1 write_inst(0xc0); lcd_show(" Fre: (Hz)"); write_inst(0xc5);
134 1 }
135 //------------------------------------------
136 void ran_port(void)
137 {cls();
138 1 write_inst(0x80); lcd_show("importation data");
139 1 write_inst(0xc0); lcd_show(" Ran: (v) "); write_inst(0xc7);
140 1 }
141 //-----------------------------------------
142 void mut_port(void)
143 {cls();
144 1 write_inst(0x80); lcd_show("importation data");
145 1 write_inst(0xc0); lcd_show("Mut: (Ran) "); write_inst(0xc4);
146 1 }
147 //---------------------------------------------
148 void is_right(void)
149 {cls();
150 1 write_inst(0x80); lcd_show(" The operation ");
151 1 write_inst(0xc0); lcd_show(" is right ");
152 1 }
153 //----------------------------------------------------------
154 void of_scope(void)
155 {cls();
156 1 write_inst(0x80); lcd_show(" Sorry ");
157 1 write_inst(0xc0); lcd_show("beyond of scope ");
158 1 }
159 //--------------------------------------------------
160 void none_data(void)
161 {cls();
162 1 write_inst(0x80); lcd_show(" Please input ");
163 1 write_inst(0xc0); lcd_show(" first the data ");
164 1 }
165 //-------------------------------------------送第一路频率数据
166 void send_one_fre(ulong x)
167 {
168 1 ulong *y; uchar *a; uchar *b; uchar *c; uchar *d;
169 1 y=0x40; a=0x40; b=0x41; c=0x42; d=0x43; *y=x;
170 1 control=control|0xf0; //无操作
171 1 send_fpga=*d; //先送低字节
172 1 control=control&0x07; //送低字节控制数据
173 1 control=control|0xf0;
174 1 send_fpga=*c;
175 1 control=control&0x87;
176 1 control=control|0xf0;
177 1 send_fpga=*b;
178 1 control=control&0x47;
179 1 control=control|0xf0;
C51 COMPILER V7.20 DDS 07/30/2005 16:03:15 PAGE 4
180 1 send_fpga=*a;
181 1 control=control&0xc7;
182 1 control=control|0xf0;
183 1 control=control&0x27; //完成频率发确认信号
184 1 }
185 //-------------------------------------------送第二路频率数据
186 void send_two_fre(ulong x)
187 {
188 1 ulong *y; uchar *a; uchar *b; uchar *c; uchar *d;
189 1 y=0x40; a=0x40; b=0x41; c=0x42; d=0x43; *y=x;
190 1 control=control|0xf8; //无操作
191 1 send_fpga=*d; //先送低字节
192 1 control=control&0x0f; //送低字节控制数据
193 1 control=control|0xf8;
194 1 send_fpga=*c;
195 1 control=control&0x8f;
196 1 control=control|0xf8;
197 1 send_fpga=*b;
198 1 control=control&0x4f;
199 1 control=control|0xf8;
200 1 send_fpga=*a;
201 1 control=control&0xcf;
202 1 control=control|0xf8;
203 1 control=control&0x2f; //完成频率发确认信号
204 1 }
205 //------------------------------------------送第一路幅度数据
206 void send_one_ran(uchar x)
207 {
208 1 control=control|0xf8;
209 1 send_fpga=x;
210 1 control=control&0x67; //送控制字
211 1 control=control|0xf0;
212 1 }
213 //---------------------------------------送第二路幅度数据
214 void send_two_ran(uchar x)
215 {
216 1 control=control|0xf8;
217 1 send_fpga=x;
218 1 control=control&0x6f; //送控制字
219 1 control=control|0xf8;
220 1 }
221 //------------------------------------------送第一路波形
222 void send_one_wave(uchar x)
223 {
224 1 control=control|0xf8;
225 1 send_fpga=x;
226 1 control=control&0xa7; //送控制字
227 1 control=control|0xf8;
228 1 }
229 //------------------------------------------送第二路波形
230 void send_two_wave(uchar x)
231 {
232 1 control=control|0xf8;
233 1 send_fpga=x;
234 1 control=control&0xaf; //送控制字
235 1 control=control|0xf8;
236 1 }
237 //----------------------------------------送相位数据
238 void send_mut(uint x)
239 {
240 1 uint *y; uchar *a; uchar*b;
241 1 y=0x40;a=0x40;b=0x41; *y=x;
C51 COMPILER V7.20 DDS 07/30/2005 16:03:15 PAGE 5
242 1 control=control|0xf8;
243 1 send_fpga=*b;
244 1 control=control&0xe7;
245 1 control=control|0xf8;
246 1 send_fpga=*a;
247 1 control=control&0x17;
248 1 control=control|0xf8;
249 1 control=control&0x97;
250 1 }
251 //------------------------------------------输出完数据后全部清零
252 void clrs(void)
253 {ulong *z;
254 1 z=0x40;
255 1 *z=0x00;
256 1 }
257 //---------------------------------------------------------各按键功能
258 void zero(void)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -