📄 keyp.lst
字号:
C51 COMPILER V8.02 KEYP 03/12/2008 10:09:41 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE KEYP
OBJECT MODULE PLACED IN keyp.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE keyp.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include<2.h>
*** WARNING C318 IN LINE 1 OF keyp.c: can't open file '2.h'
2 #include<math.h>
3 #include<stdio.h>
4 #include<intrins.h>
5 #include <absacc.h>
6 #include <setjmp.h>
7 #include<string.h>
8 void main(void)
9 {
10 1 ssp=20;
*** ERROR C202 IN LINE 10 OF KEYP.C: 'ssp': undefined identifier
11 1 ver=1;
*** ERROR C202 IN LINE 11 OF KEYP.C: 'ver': undefined identifier
12 1
13 1 initLCD();
14 1 LCDwriteByte(0x01,0);
15 1 CPRST=NORM;
16 1 FLASHADDR=0xffff;
17 1 disp_page();
18 1 Timer4_Init(N);
19 1 while(1) {
20 2 check_key();
21 2
22 2 if (FLASHADDR!=0xFFFF) //有闪烁
23 2 {
24 3 if (numm%2==0)
25 3 DATALCD[FLASHADDR]=FLASHDATA[FLASHTAB];
26 3 else
27 3 DATALCD[FLASHADDR]=' ';
28 3 }
29 2 LCDwritePage();
30 2 }
31 1 }
32 void initLCD(void)
33 {
34 1 delayus(40000); //wait 40ms
35 1 CLRBIT(P4,RSTLCD); //power on to reset >50ns
36 1 delayus(1000); //1ms,reset pulse width >10us
37 1 SETBIT(P4,RSTLCD);
38 1 delayus(1000);
39 1 CLRBIT(P4,CSLCD);
40 1 delayus(1000);
41 1 CLRBIT(P4,SCKLCD);
42 1 delayus(1000);
43 1 LCDwriteByte(0x30,0); //base instruction set,功能设定,基本指令集操作
44 1 LCDwriteByte(0x30,0); //base instruction set
45 1 LCDwriteByte(0x01,0); //clr screen,>10ms,清除显示屏幕,把DDRAM位址计数器调整为“00H”
46 1 delayus(10000);
47 1 LCDwriteByte(0x06,0); //move direction of cursor & screen,光标右移,整体显示不移动
48 1 LCDwriteByte(0x0C,0); //display on,no cursor,整体显示ON, 游标OFF,游标位置OFF
49 1 }
50 void check_busyLCD(void)
51 { unsigned char ctemp;
52 1 unsigned char dat;
C51 COMPILER V8.02 KEYP 03/12/2008 10:09:41 PAGE 2
53 1 unsigned char LCDctr=0xFC;
54 1
55 1 for (ctemp=8;ctemp>0;ctemp--) //syn bit string
56 1 {
57 2 CLRBIT(P4,SCKLCD); //上升沿写
58 2 if (ISBITSET(LCDctr,ctemp-1))
59 2 SETBIT(P4,STDLCD);
60 2 else
61 2 CLRBIT(P4,STDLCD);
62 2 delayus(2); //SCLK width>0.3us
63 2 SETBIT(P4,SCKLCD);
64 2 delayus(2);
65 2 }
66 1 dat=STDLCD;
67 1 while((dat&0x80)==0x80);
68 1 }
69 //LCDctrl=1 for data, =0 for command
70 void LCDwriteByte(unsigned char LCDdata,unsigned char LCDctrl)
71 {
72 1 unsigned int itemp;
73 1 unsigned char ctemp;
74 1 if (LCDctrl==1) LCDctrl=0xFA;
75 1 else LCDctrl=0xF8;
76 1 itemp=(LCDdata&0xF0)*256+(LCDdata&0x0F)*16;// 把数据转化为16位的十进制数
77 1 SETBIT(P4,CSLCD); //选中液晶
78 1 //写同步字符
79 1 for (ctemp=8;ctemp>0;ctemp--) //syn bit string
80 1 {
81 2 CLRBIT(P4,SCKLCD); //上升沿写
82 2 if (ISBITSET(LCDctrl,ctemp-1))
83 2 SETBIT(P4,STDLCD);
84 2 else
85 2 CLRBIT(P4,STDLCD);
86 2 delayus(2); //SCLK width>0.3us
87 2 SETBIT(P4,SCKLCD);
88 2 delayus(2);
89 2 }
90 1 //写数据或指令
91 1 for (ctemp=16;ctemp>0;ctemp--) //1 byte
92 1 {
93 2 CLRBIT(P4,SCKLCD);
94 2 if (ISBITSET(itemp,ctemp-1))
95 2 SETBIT(P4,STDLCD);
96 2 else
97 2 CLRBIT(P4,STDLCD);
98 2 delayus(2);
99 2 SETBIT(P4,SCKLCD);
100 2 delayus(2);
101 2 }
102 1 CLRBIT(P4,CSLCD);
103 1
104 1 }
105
106 void LCDwritePage(void)
107 {
108 1 unsigned char ctemp;
109 1 check_busyLCD();
110 1 for (ctemp=0;ctemp<32;ctemp++)
111 1 {
112 2 LCDwriteByte(LCDgetPos(ctemp),0); //position
113 2 LCDwriteByte(DATALCD[2*ctemp],1); //high byte
114 2 delayus(1000);
C51 COMPILER V8.02 KEYP 03/12/2008 10:09:41 PAGE 3
115 2 LCDwriteByte(DATALCD[2*ctemp+1],1); //low byte
116 2 }
117 1 }
118
119 unsigned char LCDgetPos(unsigned char LCDpos)
120 {
121 1 unsigned char row,col;
122 1 row=LCDpos/8; //row=0-3
123 1 col=LCDpos-row*8; //col=0-8
124 1 return (HZpos[row]+col);
125 1 }
126 //重载,不复制字符串结束符0x00(\0)
127 void ncstrcpy(unsigned char *dst, const unsigned char *src)
128 {
129 1 while (*src!=0x00)
130 1 *dst++=*src++;
131 1 }
132 void Initial(void)
133 {
134 1
135 1 P3MDOUT=0x00;
136 1 P74OUT =0x00;
137 1 WDTCN =0x07; //WATCHDOG TIMER CONTROL,Set WDT max interval
138 1 WDTCN =0xDE; //disable WDT
139 1 WDTCN =0xAD;
140 1 RSTSRC =0x00;
141 1 PCON=0x90;
142 1 XBR0=0x04;
143 1 XBR1=0x00;
144 1 XBR2=0x40;//允许交叉开关和弱上拉
145 1 EA=1;
146 1 OSCXCN =0x67; //外部时钟为晶体振荡器方式
147 1 OSCICN =0x08; //选择外部振荡器作为系统时钟,内部振荡典型值为2MHZ;
148 1 P0MDOUT|=0x01;
149 1
150 1
151 1 //REF0CN=0X03;//允许内部VREF发生器
152 1 }
153
154 void Timer4_Init(unsigned int counts)
155 {
156 1 T4CON=0; //停止定时器,设置为自动重载方式
157 1 CKCON=0x00; //定时器4使用系统时钟的12分频;
158 1 EIE2=0x04; //允许定时器4溢出产生中断;
159 1 EIP2=0x04; //设置定时器4中断为高优先级;
160 1 RCAP4L=counts;
161 1 RCAP4H=counts>>8;
162 1 TH4=RCAP4H;
163 1 TL4=RCAP4L;
164 1
165 1 T4CON=0x04; //允许定时器4,并设置为自动重载方式;
166 1 }
167 void Timer4_ISR (void) interrupt 16
168 {
169 1
170 1 T4CON &=~0x80; //清除溢出标志位
171 1 num++;
172 1 if(num%100==0)
173 1 { numm++;
174 2 }
175 1
176 1 }
C51 COMPILER V8.02 KEYP 03/12/2008 10:09:41 PAGE 4
177 void delayus (unsigned long tdelay)
178 {
179 1 tdelay=tdelay/2;
-
-
180 1 while (tdelay>0)
181 1 tdelay--;
182 1 }
183
184 //-------------key-----------------------
185 void check_key(void)
186 {
187 1 SETBIT(P3,keyenter);
188 1 SETBIT(P3,keyesc);
189 1 SETBIT(P3,keyadd);
190 1 SETBIT(P3,keysub);
191 1 ckey=((~P3)&0xF0);
192 1 if(ckey!=0){
193 2 if (keyenterflag==0)
194 2 { msg_key();
195 3 keyenterflag=1;
196 3
197 3 }
198 2
199 2 else
200 2 keyenterflag=0;
201 2 }
202 1 }
203
204
205 void msg_key(void)
206 { unsigned char i1;
207 1 i1=0;
208 1 IKEYSTUS=TBSTUS[i1];
209 1 while (IKEYSTUS!=CPRST)
210 1 {
211 2 i1+=4;
212 2 IKEYSTUS=TBSTUS[i1];
213 2 }
214 1 i1++;
215 1 IKEYSTUS=TBSTUS[i1];
216 1 while(IKEYSTUS!=0&&(IKEYSTUS!=ckey))
217 1 {
218 2 i1+=4;
219 2 IKEYSTUS=TBSTUS[i1];
220 2 }
221 1 CPRST=TBSTUS[i1+2];
222 1 CPRAMADDR=TBSTUS[i1+1];
223 1 switch(CPRAMADDR)
224 1 {
225 2
226 2 case NEXTTRIGLE1:disp_sigle();break;
227 2 case NEXTTRIGLE2:disp_cunchu();break;
228 2 case NEXTTRIGLE3:disp_page();break;
229 2 case SETSUB:set_SUB();break;
230 2
231 2 case SETCLEAR:set_CLEAR();break;
232 2 case SETNEXT:set_NEXT();break;
233 2 case SETADD: set_ADD();break;
234 2 // case NEXTPAGE3:disp_page0();break;
235 2 //case SETNEXT2:set_NEXT();break;
236 2 // case SETADD2:set_ADD1();break;
C51 COMPILER V8.02 KEYP 03/12/2008 10:09:41 PAGE 5
237 2 }
238 1 ckey=0;
239 1 }
240 void set_CLEAR(void)
241 {
242 1 disp_page();
243 1 }
244 void disp_page (void)
245 {
246 1 LCDwriteByte(0x01,0);
247 1 sprintf(DATALCD+26,"%2d",ssp);
248 1 sprintf(DATALCD+44,"%3f",ver);
249 1 ncstrcpy(DATALCD+4,"数字示波器");
250 1 ncstrcpy(DATALCD+16,"扫描速度 s
*** ERROR C305 IN LINE 250 OF keyp.c: unterminated string/char const
251 1 ");
*** ERROR C305 IN LINE 251 OF keyp.c: unterminated string/char const
252 1 ncstrcpy(DATALCD+32,"垂直灵敏度 v");
253 1 ncstrcpy(DATALCD+48,"连续显示 ");
254 1 LCDwritePage();
255 1 FLASHADDR=0XFFFF;
256 1 }
257 void disp_sigle(void)
258 {
259 1 ncstrcpy(DATALCD+48,"单次触发 ");
260 1 LCDwritePage();
261 1 }
262 void disp_cunchu(void)
263 {
264 1 ncstrcpy(DATALCD+48,"存储 ");
265 1 LCDwritePage();
266 1 }
C51 COMPILATION COMPLETE. 1 WARNING(S), 4 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -