📄 ad9851.lst
字号:
C51 COMPILER V7.06 AD9851 11/03/2008 03:20:05 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE AD9851
OBJECT MODULE PLACED IN ad9851.OBJ
COMPILER INVOKED BY: F:\keil c\C51\BIN\C51.EXE ad9851.c BROWSE DEBUG OBJECTEXTEND TABS(16)
stmt level source
1 /*************************************************
2 工程:直接数字频率合成
3 日期:07.09.01
4 *************************************************/
5 #include<reg52.h>
6 #include <intrins.h>
7 #include<max7219.h>
8 #include <keyscan.h>
9 #define uchar unsigned char
10 #define uint unsigned int
11
12 sbit ad9851_d7=P1^0;
13 sbit ad9851_clk=P1^1;
14 sbit ad9851_load=P1^2;
15
16 /*uchar c=0;
17 char count0=0;
18 char count1=0;
19 char count2=0;
20 char count3=0;
21 char count4=0;
22 char count5=0;
23 char count6=0;
24 char count7=0;*/
25 unsigned long temp=0;
26 /*****************************************
27 函数:void display(unsigned long tmp)
28 功能:显示
29 *****************************************/
30 void display(unsigned long tmp)
31 {
32 1 send_7219(k0,tmp/10000000);
33 1 send_7219(k1,tmp%10000000/1000000);
34 1 send_7219(k2,tmp%1000000/100000);
35 1 send_7219(k3,tmp%100000/10000);
36 1 send_7219(k4,tmp%10000/1000);
37 1 send_7219(k5,tmp%1000/100);
38 1 send_7219(k6,tmp%100/10);
39 1 send_7219(k7,tmp%10);
40 1 }
41
42 /************************************************
43 函数:void write_dds()
44 功能:向AD9851写需要的频率,暂时没有控制相位
45 *************************************************/
46 void write_dds(unsigned long dat)
47 {
48 1 uchar i=0;
49 1 uchar tt=0x00000011;
50 1 ad9851_load=0;
51 1 ad9851_clk=0;
52 1 for(i=32;i>0;i--)
53 1 {
54 2 ad9851_clk=0;
55 2 delay(5);
C51 COMPILER V7.06 AD9851 11/03/2008 03:20:05 PAGE 2
56 2 if(dat&0x00000001)ad9851_d7=1;
57 2 else ad9851_d7=0;
58 2 delay(2);
59 2 ad9851_clk=1;
60 2 delay(5);
61 2 dat=dat>>1;
62 2 }
63 1 for(i=8;i>0;i--)
64 1 {
65 2 ad9851_clk=0;
66 2 delay(5);
67 2 if(tt&0x00000001)ad9851_d7=1;
68 2 else ad9851_d7=0;
69 2 delay(2);
70 2 ad9851_clk=1;
71 2 delay(5);
72 2 tt=tt>>1;
73 2 }
74 1 ad9851_load=1;
75 1 ad9851_clk=0;
76 1 delay(2);
77 1 ad9851_load=0;
78 1 }
79 /*************************************************
80 工程:写进AD9851的真正数据
81 *************************************************/
82 void write_ad9851(unsigned long freq)
83 {
84 1 unsigned long dds;
85 1 dds=23.860929422*freq; //180M
86 1 //dds=23.860929922*freq;
87 1 write_dds(dds);
88 1 }
89 /*******************************************
90 中断函数
91 ********************************************
92 void time_1(void) interrupt 3
93 {
94 TH1=0x3c;
95 TL1=0xb0;
96 c+=1;
97 if(c==8)c=0;
98 send_7219(k[c],0x7f);
99 TR1=0;
100 }
101
102 /*******************************************
103 主函数
104 ********************************************/
105 void main()
106 {
107 1 TMOD=0x01;
108 1 TH1=0x3c;
109 1 TL1=0xb0;
110 1 ET1=1;
111 1 EA=1;
112 1 write_7219();
113 1 init_7219();
114 1 ad9851_load=0;
115 1 ad9851_clk=0;
116 1 delay(1);
117 1 ad9851_clk=1;
C51 COMPILER V7.06 AD9851 11/03/2008 03:20:05 PAGE 3
118 1 ad9851_load=1; //把AD9851设为串行输入法
119 1 while(1)
120 1 {
121 2 keyscan();
122 2 if(key_flag)
123 2 {
124 3 if(key_val<10)
125 3 {
126 4 temp=temp*10+key_val;
127 4 if(temp>=19999999)temp=90000000;
128 4 display(temp);
129 4 }
130 3 else
131 3 write_ad9851(temp);
132 3 }
133 2 /*if(key_val==9)
134 2 {
135 2 delay(100);
136 2 if(key_val==9)
137 2 TR1=1;
138 2 }
139 2 if(key_val==14)
140 2 {
141 2 switch (c)
142 2 {
143 2 case 0 : count0+=1;if(count0==10)count0=0;send_7219(k0,count0);break;
144 2 case 1 : count1+=1;if(count1==10)count1=0;send_7219(k1,count1);break;
145 2 case 2 : count2+=1;if(count2==10)count2=0;send_7219(k2,count2);break;
146 2 case 3 : count3+=1;if(count3==10)count3=0;send_7219(k3,count3);break;
147 2 case 4 : count4+=1;if(count4==10)count4=0;send_7219(k4,count4);break;
148 2 case 5 : count5+=1;if(count5==10)count5=0;send_7219(k5,count5);break;
149 2 case 6 : count6+=1;if(count6==10)count6=0;send_7219(k6,count6);break;
150 2 case 7 : count7+=1;if(count7==10)count7=0;send_7219(k7,count7);break;
151 2 }
152 2 }
153 2 if(key_val==12)
154 2 {
155 2 switch (c)
156 2 {
157 2 case 0 : count0-=1;if(count0<0)count0=0;send_7219(k0,count0);break;
158 2 case 1 : count1-=1;if(count1<0)count1=0;send_7219(k1,count1);break;
159 2 case 2 : count2-=1;if(count2<0)count2=0;send_7219(k2,count2);break;
160 2 case 3 : count3-=1;if(count3<0)count3=0;send_7219(k3,count3);break;
161 2 case 4 : count4-=1;if(count4<0)count4=0;send_7219(k4,count4);break;
162 2 case 5 : count5-=1;if(count5<0)count5=0;send_7219(k5,count5);break;
163 2 case 6 : count6-=1;if(count6<0)count6=0;send_7219(k6,count6);break;
164 2 case 7 : count7-=1;if(count7<0)count7=0;send_7219(k7,count7);break;
165 2 }
166 2 }
167 2 temp=count0*10000000+count1*1000000+count2*100000+
168 2 count3*10000+count4*1000+count5*100+count6*10+count7;
169 2 display(temp);
170 2 if(key_val==15)
171 2 {
172 2 TR1=0;
173 2 write_ad9851(temp);
174 2 }
175 2 }*/
176 2 }
177 1 }
C51 COMPILER V7.06 AD9851 11/03/2008 03:20:05 PAGE 4
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 915 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 5 8
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -