📄 wkq.lst
字号:
C51 COMPILER V7.06 WKQ 11/18/2005 20:51:25 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE WKQ
OBJECT MODULE PLACED IN wkq.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE wkq.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <AT89X51.H> //器件配置文件
2 #include <intrins.h>
3 sbit LCM_RS=P3^3; //引脚定义
4 sbit LCM_RW=P3^4; //引脚定义
5 sbit LCM_EN=P3^5; //引脚定义
6 sbit OUT=P3^6; //控制继电器
7 sbit TSOR=P3^7; //温度测试端
8 #define Busy 0x80 //常量定义
9 #define uchar unsigned char
10 #define uint unsigned int
11 #define DATAPORT P1
12 #define reset() {WDT=0x1e;WDT=0xe1;}// 看门狗启动/复位宏定义
13 sfr WDT=0xa6;//看门狗寄存器定义
14 bit ON_OFF;
15 bit outflag;
16 //==============================================
17 uchar temp1,temp2;
18 uchar cnt;
19 uchar deda,sec; //时间变量
20 char min,hour;
21 char set,T;
22 uchar ReadStatusLCM(void);//读数据到MCU子函数声明
23 uchar code str0[]={"--- : : --- "};//待显字符串
24 uchar code str1[]={"SET: C SA: . C"};
25 uchar code str2[]={" "};//待显空字符串
26 //====================函数声明=======================
27 void fun0(void);
28 void fun1(void);
29 void fun2(void);
30 void fun3(void);
31 void set_adj(void);
32 void inc_key(void);
33 void dec_key(void);
34 void key(void);
35 void gettempTS(void);
36 void initTS(void);
37 uchar readBTS(void);
38 void writeBTS(uchar byte);
39 void resetTS(void);
40 bit readTS(void);
41 void write1TS(void);
42 void write0TS(void);
43 void delay15us(void);
44 void delay60us(void);
45
46 //********延时K*1mS,12.000MHz*********
47 void delay(uint k)//函数名为delay的延时子函数。定义k为无符号整型变量
48 { //delay函数开始
49 1 uint i,j; //定义i、j为无符号整型变量
50 1 for(i=0;i<k;i++)
51 1 { //for循环语句开始
52 2 for(j=0;j<60;j++) // for循环语句开始
53 2 {;}
54 2 reset()} //两个for循环体
55 1 } //delay函数结束
C51 COMPILER V7.06 WKQ 11/18/2005 20:51:25 PAGE 2
56 /*-----------------------------写指令到LCM子函数-------------------------------*/
57 void WriteCommandLCM(uchar WCLCM, uchar BusyC) /*函数名为WriteCommandLCM 的写指令到LCM子函数。定义WCLCM、B
-usyC 为无符号字符型变量*/
58 { //WriteCommandLCM函数开始
59 1 if(BusyC)ReadStatusLCM(); /*若BusyC为"1",则调用ReadStatusLCM子函数进行忙检测*/
60 1 DATAPORT=WCLCM; //将变量WCLCM中的指令传送至P1口
61 1 LCM_RS=0; //选中指令寄存器
62 1 LCM_RW=0; //写模式
63 1 LCM_EN=0; //置LCM_EN端为低电平
64 1 LCM_EN=0; //置LCM_EN端为低电平,延时一会儿
65 1 LCM_EN=1; //置LCM_EN端为高电平,写入使能
66 1 } // WriteCommandLCM函数结束
67 /*----------------------------写数据到LCM子函数-------------------------------*/
68 void WriteDataLCM(uchar WDLCM) /*函数名为WriteDataLCM 的写数据到LCM子函数。定义WDLCM 为无符号字符型变量*/
69 { // WriteDataLCM函数开始
70 1 ReadStatusLCM(); //调用ReadStatusLCM子函数检测忙信号
71 1 DATAPORT=WDLCM; //将变量WDLCM中数据传送至P1口
72 1 LCM_RS=1; //选中数据寄存器
73 1 LCM_RW=0; //写模式
74 1 LCM_EN=0; //置LCM_EN端为低电平
75 1 LCM_EN=0; //置LCM_EN端为低电平,延时一会儿
76 1 LCM_EN=1; //置LCM_EN端为高电平,写入使能
77 1 } // WriteDataLCM函数结束
78 /*--------------------------------读数据到MCU子函数---------------------------*/
79 /*uchar ReadDataLCM(void) //函数名为ReadDataLCM的读数据到MCU子函数
80 { // ReadDataLCM函数开始
81 LCM_RS=1; //选中数据寄存器
82 LCM_RW=1; //读模式
83 LCM_EN=0; //置LCM_EN端为低电平
84 LCM_EN=0; //置LCM_EN端为低电平,延时一会儿
85 LCM_EN=1; //置LCM_EN端为高电平,读使能
86 return(DATAPORT); //返回P1口的内容
87 }*/ // ReadDataLCM函数结束
88
89 /*--------------------------------读状态到MCU子函数-----------------------------*/
90 uchar ReadStatusLCM(void) //函数名为ReadStatusLCM的读状态到MCU子函数
91 { //ReadStatusLCM函数开始
92 1 DATAPORT=0xFF; //置P1口为全1
93 1 LCM_RS=0; //选中指令寄存器
94 1 LCM_RW=1; //读模式
95 1 LCM_EN=0; //置LCM_EN端为低电平
96 1 LCM_EN=0; //置LCM_EN端为低电平,延时一会儿
97 1 LCM_EN=1; //置LCM_EN端为高电平,读使能
98 1 while(P1&Busy); /*检测忙信号。当P1口内容与Busy(80H)相与后不为零时,程序原地踏步*/
99 1 return(DATAPORT); //返回P1口的内容
100 1 } // ReadStatusLCM函数结束
101
102 /*--------------------------LCM初始化子函数----------------------------*/
103 void InitLcd() //函数名为InitLcd 的LCM初始化子函数
104 { // InitLcd函数开始
105 1 WriteCommandLCM(0x38,1);//8位数据传送,2行显示,5*7字形,检测忙信号
106 1 WriteCommandLCM(0x08,1);//关闭显示,检测忙信号
107 1 WriteCommandLCM(0x01,1);//清屏,检测忙信号
108 1 WriteCommandLCM(0x06,1);//显示光标右移设置,检测忙信号
109 1 WriteCommandLCM(0x0c,1);//显示屏打开,光标不显示、不闪烁,检测忙信号
110 1 } // InitLcd函数结束
111
112 /*-------------------显示指定座标的一个字符子函数---------------------------*/
113 void DisplayOneChar(uchar X,uchar Y,uchar DData)
114 {
115 1 Y&=1;
116 1 X&=15;
C51 COMPILER V7.06 WKQ 11/18/2005 20:51:25 PAGE 3
117 1 if(Y)X|=0x40;
118 1 X|=0x80;
119 1 WriteCommandLCM(X,0);
120 1 WriteDataLCM(DData);
121 1 }
122
123 /*--------------------显示指定座标的一串字符子函数----------------------*/
124 void DisplayListChar(uchar X,uchar Y,uchar code *DData)
125 {
126 1 uchar ListLength=0;
127 1 Y&=0x1;
128 1 X&=0xF;
129 1 while(X<=15)
130 1 {
131 2 DisplayOneChar(X,Y,DData[ListLength]);
132 2 ListLength++;
133 2 X++;
134 2 }
135 1 }
136 //=================================================
137 void init_timer0(void) //定时器T0初始化
138 {
139 1 TMOD=0x01;
140 1 TH0=-(50235/256);
141 1 TL0=-(50235%256);
142 1 TR0=1;
143 1 ET0=1;EA=1;
144 1 }
145 //==================================================
146 void time_zd0(void) interrupt 1 using 1 //定时器T0中断子函数
147 {
148 1 TH0=-(50235/256);
149 1 TL0=-(50235%256);
150 1 deda++;cnt++;
151 1 if(deda>=20){sec++;deda=0;}
152 1 if(sec>=60){min++;sec=0;}
153 1 if(min>=60){hour++;min=0;}
154 1 if(hour>=24){hour=0;}
155 1 if(cnt>=6)cnt=0;
156 1 key(); //扫描键盘
157 1 }
158
159 //==================================
160 void fun0(void) //液晶显示子函数0
161 {
162 1 WriteCommandLCM(0x0c,1);//显示屏打开,光标不显示、不闪烁,检测忙信号
163 1 DisplayListChar(0,0,str0);
164 1 DisplayListChar(0,1,str1);
165 1 //===============================
166 1 DisplayOneChar(3,0,hour/10+0x30);// 液晶上显示小时
167 1 DisplayOneChar(4,0,hour%10+0x30);
168 1 //=========================
169 1 DisplayOneChar(6,0,min/10+0x30); // 液晶上显示分
170 1 DisplayOneChar(7,0,min%10+0x30);
171 1 //==============================
172 1 DisplayOneChar(9,0,sec/10+0x30); // 液晶上显示秒
173 1 DisplayOneChar(10,0,sec%10+0x30);
174 1 //=================================
175 1 DisplayOneChar(4,1,T/10+0x30); // 液晶上显示设定的温度值
176 1 DisplayOneChar(5,1,T%10+0x30);
177 1 //=================================
178 1 DisplayOneChar(11,1,temp1/10+0x30); // 液晶上显示测得的温度值
C51 COMPILER V7.06 WKQ 11/18/2005 20:51:25 PAGE 4
179 1 DisplayOneChar(12,1,temp1%10+0x30);
180 1 DisplayOneChar(14,1,temp2+0x30);
181 1 //================================
182 1 if(ON_OFF==0)// 若控温标志为0
183 1 {
184 2 DisplayOneChar(14,0,0x4f);// 液晶上显示不控温的图标
185 2 DisplayOneChar(15,0,0x46);
186 2 }
187 1 else
188 1 {
189 2 DisplayOneChar(14,0,0x4f); // 否则液晶上显示控温的图标
190 2 DisplayOneChar(15,0,0x4e);
191 2 if(outflag==1)DisplayOneChar(0,0,0x7c);
192 2 else DisplayOneChar(0,0,0xef);
193 2 }
194 1 //============================
195 1
196 1 }
197 /*******************************************/
198 void fun1(void) //液晶显示子函数1
199 {
200 1 WriteCommandLCM(0x0c,1);//显示屏打开,光标不显示、不闪烁,检测忙信号
201 1 DisplayListChar(0,0,str0);
202 1 DisplayListChar(0,1,str1);
203 1 //=========================
204 1 DisplayOneChar(6,0,min/10+0x30);
205 1 DisplayOneChar(7,0,min%10+0x30);
206 1 //==============================
207 1 DisplayOneChar(9,0,sec/10+0x30);
208 1 DisplayOneChar(10,0,sec%10+0x30);
209 1 //=================================
210 1 DisplayOneChar(4,1,T/10+0x30);
211 1 DisplayOneChar(5,1,T%10+0x30);
212 1 //=================================
213 1 DisplayOneChar(11,1,temp1/10+0x30);
214 1 DisplayOneChar(12,1,temp1%10+0x30);
215 1 DisplayOneChar(14,1,temp2+0x30);
216 1 //=================================
217 1 WriteCommandLCM(0x0f,1);//显示屏打开,光标显示、闪烁,检测忙信号
218 1 DisplayOneChar(3,0,hour/10+0x30);
219 1 DisplayOneChar(4,0,hour%10+0x30);
220 1 }
221 /********************************************/
222 void fun2(void) //液晶显示子函数2
223 {
224 1 WriteCommandLCM(0x0c,1);//显示屏打开,光标不显示、不闪烁,检测忙信号
225 1 DisplayListChar(0,0,str0);
226 1 DisplayListChar(0,1,str1);
227 1 //=========================
228 1 DisplayOneChar(3,0,hour/10+0x30);
229 1 DisplayOneChar(4,0,hour%10+0x30);
230 1 //=================================
231 1 DisplayOneChar(9,0,sec/10+0x30);
232 1 DisplayOneChar(10,0,sec%10+0x30);
233 1 //=================================
234 1 DisplayOneChar(4,1,T/10+0x30);
235 1 DisplayOneChar(5,1,T%10+0x30);
236 1 //=================================
237 1 DisplayOneChar(11,1,temp1/10+0x30);
238 1 DisplayOneChar(12,1,temp1%10+0x30);
239 1 DisplayOneChar(14,1,temp2+0x30);
240 1 //===================================
C51 COMPILER V7.06 WKQ 11/18/2005 20:51:25 PAGE 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -