📄 51.lst
字号:
C51 COMPILER V7.04 51 10/09/2008 16:47:44 PAGE 1
C51 COMPILER V7.04, COMPILATION OF MODULE 51
OBJECT MODULE PLACED IN 51.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 51.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <reg52.h> /*头文件的包含*/
2 #include "IIC.h"
3 #include "display.h"
4 #include "define.h"
5
6
7 #define PCF8583 0xa0 /*10100000--A0 write*/
8 #define PCF8583_Ctr 0x00/*control register*/
9
10
11 #define Sen 0x02
12 #define Min 0x03
13 #define Hour 0x04
14
15 char sen,min,hour; /*需要用到-1,不用uchar*/
16 uchar flag; /*进入设置时钟标志*/
17 uchar wflag; /*故障标志 0-正常*/
18 uchar id; /*故障发生点 1-8*/
19 uchar point; /*记录EEPROM的当前页的目前的地址*/
20 uchar recvflag; /*接收到串口信息标志*/
21 uchar EEP;
22
23
24 /*s1为进入和退出设置键,s2为+键,s3为-键,s4为循环键*/
25 sbit s1=P3^2;
26 sbit s2=P3^3;
27 sbit s3=P3^4;
28 sbit s4=P3^5;
29
30 sbit s5=P1^0;
31 sbit s6=P1^1;
32 sbit s7=P1^2;
33 sbit s8=P1^3;
34 sbit s9=P1^4;
35 sbit s10=P1^5;
36 sbit s11=P1^5;
37 sbit s12=P1^6;
38 /*
39 对时间进行设置
40 */
41
42 void keyscan()
43 {
44 1
45 1 uchar roll=0; /*roll=0表示设置秒;roll=1表示设置分;roll=2表示设置时*/
46 1 //rd=0;
47 1
48 1 if(s1==0)
49 1 {
50 2 delay_ms(5); /*消抖*/
51 2 if(s1==0) /*确定键已经按下*/
52 2 {
53 3 flag=!flag; /* 1 标志进入时间设置状态*/
54 3 while(!s1); /*等待按键松开*/
55 3 if(1==flag)
C51 COMPILER V7.04 51 10/09/2008 16:47:44 PAGE 2
56 3 {
57 4 roll=0;
58 4 light(roll); /*显示在秒设置处*/
59 4 }
60 3 else if(0==flag) /*退出时间设置状态*/
61 3 {
62 4 ISendByte(PCF8583,Sen,sen);
63 4 ISendByte(PCF8583,Min,min);
64 4 ISendByte(PCF8583,Hour,hour); /*写入新的时间到8583*/
65 4 light(4); /*全熄灭*/
66 4 }
67 3 }
68 2 }
69 1
70 1 if(flag==1) /*在设置状态下*/
71 1 {
72 2 if(s4==0) /*进入选择设置位,选择要设置的单位*/
73 2 {
74 3 delay_ms(5); /*消抖*/
75 3 if(s4==0) /*确定键已经按下*/
76 3 {
77 4 while(!s4); /*等待按键松开*/
78 4 roll++;
79 4 if(roll==3) roll=0; /*循环*/
80 4 light(roll);
81 4
82 4 }
83 3 }
84 2 if(s2==0) /*进入+状态*/
85 2 {
86 3 delay_ms(5); /*消抖*/
87 3 if(s2==0) /*确定键已经按下*/
88 3 {
89 4 while(!s2); /*等待按键松开*/
90 4 if(roll==0) /*设置秒*/
91 4 {
92 5 sen++;
93 5 if(sen==60) sen=0;
94 5 }
95 4 if(roll==1) /*设置分*/
96 4 {
97 5 min++;
98 5 if(min==60) min=0;
99 5 }
100 4 if(roll==2) /*设置时*/
101 4 {
102 5 hour++;
103 5 if(hour==24) hour=0;
104 5 }
105 4
106 4 }
107 3 }
108 2 if(s3==0) /*进入-状态*/
109 2 {
110 3 delay_ms(5); /*消抖*/
111 3 if(s3==0) /*确定键已经按下*/
112 3 {
113 4 while(!s3); /*等待按键松开*/
114 4 if(roll==0) /*设置秒*/
115 4 {
116 5 sen--;
117 5 if(sen==-1) sen=59;
C51 COMPILER V7.04 51 10/09/2008 16:47:44 PAGE 3
118 5 }
119 4 if(roll==1) /*设置分*/
120 4 {
121 5 min--;
122 5 if(min==-1) min=59;
123 5 }
124 4 if(roll==2) /*设置时*/
125 4 {
126 5 hour--;
127 5 if(hour==-1) hour=23;
128 5 }
129 4
130 4 }
131 3 }
132 2 }
133 1
134 1
135 1
136 1
137 1 }
138
139 /*
140 将发生故障的时间、故障点、修复的时间写入EEPROM,记录100个故障
141 键按下代表发生故障,记录发生故障的时间; 写入顺序 id->sen->min->hour
142 键松开代表修复故障,记录修复故障的时间。
143 */
144 void save()
145 {
146 1 /*为了避免代码重复,这里只给了S5发生故障的代码,s6,s7,s8,s9,s10,s11,s12类似*/
147 1 /*10101 A1 A0 0 确定页地址
148 1 00000 0 0 0 - 0页 0
149 1 00000 0 1 0 - 1页 2
150 1 00000 1 0 0 - 2页 4
151 1 00000 1 1 0 - 3页 6
152 1 */
153 1 EEP=0xa8; /*10101000--A8 write A2,A1是页*/
154 1
155 1 if(s5==0) /*故障*/
156 1 {
157 2 delay_ms(5); /*消抖*/
158 2 if(s5==0) /*确定键已经按下 开始写入故障的时间*/
159 2 {
160 3 wflag=1; //故障标志置位
161 3 id=1;
162 3 ISendByte(EEP,point,id);
163 3 point++;
164 3 if(0xFF==point-1)
165 3 {
166 4 point=0x00; /*页内指针复位*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -