📄 volt.lst
字号:
C51 COMPILER V7.50 VOLT 10/21/2007 16:20:34 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE VOLT
OBJECT MODULE PLACED IN volt.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE volt.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "reg52.h"
2 //#include "Port_define.h"
3 #include"DRIVER_1602.h"
4 #define uchar unsigned char
5 #define uint unsigned int
6 #define KT 30 //按键消抖参数
7
8
9 sbit K1U=P0^5;
10 sbit K1D=P0^4;
11 sbit K2U=P0^3;
12 sbit K2D=P0^2;
13 sbit K3U=P0^0;
14 sbit K3D=P0^1;
15
16 sbit cs=P1^7;
17 sbit Data=P1^4;
18 sbit clk=P1^3;
19 sbit clr=P1^6;
20 sbit ld=P1^5;
21
22 uchar key1=0,key2=0,key3=0,temp=0;
23 uint volt;
24 /**************************DAC7611驱动*********************************************/
25 void DAC7611(uint x)
26 { uchar i;
27 1 cs=0;
28 1 for(i=0;i<=11;i++)
29 1 {clk=0;
30 2 if((x&0x800)==0) Data=0;
31 2 else Data=1;
32 2 x<<=1;
33 2 clk=1;}
34 1 cs=1; }
35
36 void out(uint x)
37 {
38 1 ld=0;
39 1 clr=1;
40 1 DAC7611(x);
41 1 }
42
43 /***********************************************************************/
44 /***********************************按键扫描**************************************/
45 void key(void)
46 {uint voltemp;
47 1 voltemp=volt;
48 1 key1=(voltemp%10000)/1000;
49 1 key2=(voltemp%1000)/100;
50 1 key3=(voltemp%100)/10;
51 1 if(K1U==0)
52 1 {temp++;
53 2 if(temp>KT)
54 2 {temp=0;
55 3 key1++;}
C51 COMPILER V7.50 VOLT 10/21/2007 16:20:34 PAGE 2
56 2 }
57 1
58 1 if(K1D==0)
59 1 {temp++;
60 2 if(temp>KT)
61 2 {temp=0;
62 3 key1--;}
63 2 }
64 1
65 1
66 1 if(K2U==0)
67 1 {temp++;
68 2 if(temp>KT)
69 2 {temp=0;
70 3 key2++;}
71 2 }
72 1
73 1 if(K2D==0)
74 1 {temp++;
75 2 if(temp>KT)
76 2 {temp=0;
77 3 key2--;
78 3 if(key2>9)key2=0;}
79 2 }
80 1
81 1
82 1
83 1 if(K3U==0)
84 1 {temp++;
85 2 if(temp>KT)
86 2 {temp=0;
87 3 key3++;}
88 2 }
89 1
90 1 if(K3D==0)
91 1 {temp++;
92 2 if(temp>KT)
93 2 {temp=0;
94 3 key3--;
95 3 if(key3>9)key3=0;}
96 2 }
97 1
98 1 volt=key1*1000+key2*100+key3*10;
99 1 if(volt>=4095){volt=0;}
100 1 //if(volt>4095){volt=0;}
101 1 }
102
103 /*********************************************************************************/
104 /*****************************LCD应用层驱动*****************************************/
105 void disp(unsigned int x)
106 {
107 1 LCD_set_xy(5,0);
108 1 LCD_en_dat((x%10000)/1000+48);
109 1 LCD_en_dat('.');
110 1 LCD_en_dat((x%1000)/100+48);
111 1 LCD_en_dat((x%100)/10+48);
112 1 LCD_en_dat(x%10+48);
113 1 }
114
115 void disp1(uchar x)
116 {
117 1 LCD_set_xy(0,1);
C51 COMPILER V7.50 VOLT 10/21/2007 16:20:34 PAGE 3
118 1 LCD_en_dat((x%1000)/100+48);
119 1 LCD_en_dat((x%100)/10+48);
120 1 LCD_en_dat(x%10+48);
121 1 }
122 void disp2(uchar x)
123 {
124 1 LCD_set_xy(4,1);
125 1 LCD_en_dat((x%1000)/100+48);
126 1 LCD_en_dat((x%100)/10+48);
127 1 LCD_en_dat(x%10+48);
128 1 }
129
130 void disp3(uchar x)
131 {
132 1 LCD_set_xy(9,1);
133 1 LCD_en_dat((x%1000)/100+48);
134 1 LCD_en_dat((x%100)/10+48);
135 1 LCD_en_dat(x%10+48);
136 1 }
137
138
139 /*********************************************************************************/
140 void main(void)
141 { uint dvolt,voltreal;
142 1 P0=0xFF;
143 1
144 1 volt=0;
145 1 LCD_init();
146 1 ld=0;
147 1 clr=1;
148 1 while(1)
149 1 {dvolt=voltreal;
150 2 key();
151 2
152 2 /*
153 2 LCD_cls();//清屏
154 2
155 2 delay_nms(2);
156 2 LCD_write_string(0,0,"1602 test");
157 2 LCD_write_string(5,1,"awakening");
158 2
159 2 delay_nms(200);
160 2
161 2 LCD_cls();
162 2 delay_nms(2);
163 2 LCD_write_string(0,0,"test 1602");
164 2 LCD_write_string(0,1,"1234567890");
165 2 LCD_write_char(0,1,'a');
166 2
167 2 delay_nms(200);
168 2
169 2 */
170 2 LCD_write_string(0,0,"Volt:");
171 2 LCD_write_string(11,0,"V");
172 2 disp(volt);
173 2 disp1(key1);
174 2 disp2(key2);
175 2 disp3(key3);
176 2 // LCD_write_string(0,1,1234);
177 2 /*****************精度校正************************/
178 2 if((volt>0)&&(volt<=816))
179 2 {voltreal=volt-1;}
C51 COMPILER V7.50 VOLT 10/21/2007 16:20:34 PAGE 4
180 2 if((volt>816)&&(volt<=2000))
181 2 {voltreal=volt-2;}
182 2 if((volt>2000)&&(volt<=3200))
183 2 {voltreal=volt-3;}
184 2 if((volt>3200)&&(volt<=3900))
185 2 {voltreal=volt-4;}
186 2 if((volt>3900)&&(volt<=4095))
187 2 {voltreal=volt-5;}
188 2 /************************************************/
189 2
190 2
191 2 if(dvolt!=voltreal)
192 2 {DAC7611(voltreal);
193 3 dvolt=voltreal;
194 3 }
195 2 }
196 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 917 ----
CONSTANT SIZE = 8 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 9
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -