📄 main.lst
字号:
C51 COMPILER V7.06 MAIN 12/17/2006 14:56:13 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: E:\My Electronic\Tools\Design tools\keil7.06\C51\BIN\C51.EXE main.c LARGE OPTIMIZE(SIZE)
stmt level source
1 #include <REG52.H>
2 #include "Header.h"
3
4 unsigned char hex2asc(uchar hex);
5 unsigned char menu(unsigned char MenuNum) ;
6 unsigned char EditRing(unsigned char Num);
7 void COM_SendAll();
8 void ReadTime();
9 void Scan_RingTime(unsigned char ScanNum);
10 void Set_time();
11 void Set_NextRT(unsigned mode);
12
13 void X0() interrupt 0
14 {}
15
16 void Time0() interrupt 1
17 {
18 1 TH0=0xEE; //定时器中断,隔5ms
19 1 TL0=0x00;
20 1
21 1 if (RingFlag==1)
22 1 {
23 2 if (RingET==RingST) {RingFlag=2;Beep=0;}
24 2 }
25 1
26 1 tc++; //检测30秒内无操作则关背光
27 1 if (key_flag)
28 1 {
29 2 LCD_BK=1;
30 2 key_flag=0;
31 2 KeyT2=0;
32 2 }
33 1 else
34 1 {
35 2 KeyT++;
36 2 if (KeyT==200) {KeyT2++;KeyT=0;}
37 2 if (KeyT2==30) LCD_BK=0;
38 2 }
39 1 }
40
41 void X1() interrupt 2
42 {}
43
44 void Time1() interrupt 3
45 {}
46
47 void Com1() interrupt 4
48 {
49 1 if (RI)
50 1 {
51 2 RI=0;
52 2 Com_buff[Com_count]=SBUF;
53 2 In_flag=1;
54 2 }
55 1 }
C51 COMPILER V7.06 MAIN 12/17/2006 14:56:13 PAGE 2
56
57 void COM_SendAll()
58 {
59 1 unsigned char rMax,i,temp;
60 1 temp=Mem_Read(0x00);
61 1 rMax=1+3*temp;
62 1 for (i=0;i<rMax;i++)
63 1 {
64 2 temp=Mem_Read(i);
65 2 COM_Send(temp);
66 2 delay_ms(2);
67 2 }
68 1 }
69
70 unsigned char hex2asc(uchar hex) //16进制转ASC码
71 {
72 1 hex &=0x0f;
73 1 if (hex>9)
74 1 return ( hex - 10 + 'A' );
75 1 else
76 1 return ( hex + '0' );
77 1 }
78
79 unsigned char BCD2HEX(unsigned char BCD)
80 {
81 1 unsigned char temp1,temp2;
82 1 temp1=(BCD>>4)*10;
83 1 temp2=BCD & 0x0f;
84 1 return (temp1+temp2);
85 1 }
86
87 unsigned char HEX2BCD(unsigned char HEX)
88 {
89 1 unsigned char temp1,temp2;
90 1 temp1=(HEX/10)<<4;
91 1 temp2=HEX%10;
92 1 return (temp1+temp2);
93 1 }
94
95 void Init() //初始化
96 {
97 1 unsigned char temp;
98 1 RingFlag=0;
99 1 temp=DS1307_Read(Second ); //初始化时钟芯片
100 1 if(temp&0x80) DS1307_Write(Second,(temp&0x7f));
101 1
102 1 TH0=0xEE; //定时器中断,隔50ms读取一次时间
103 1 TL0=0x00;
104 1 TH1=0xFD; //串口波特率9600
105 1 TL1=0xFD;
106 1
107 1 TMOD=0x21; //T1以方式2工作,T0以方式0工作
108 1 SCON=0xd8; //设置串口工作方式
109 1 PCON&=0x7f; //波特率倍频
110 1 IE=0x9A; //设置中断允许
111 1 // ES=1; //开串口中断
112 1 // ET0=1; //定时器中断允许
113 1 // ET1=1;
114 1 // EA=1; //开总中断
115 1 PS=1;
116 1 LCD_init(); //初始化液晶
117 1
C51 COMPILER V7.06 MAIN 12/17/2006 14:56:13 PAGE 3
118 1 Com_flag=0;
119 1 LCD_BK=1;
120 1 key_flag=1;
121 1 RingFlag=0;
122 1 KeyT=0;
123 1 Com_over=0;
124 1 NextRingNum=1;
125 1 }
126
127 void ReadTime() //读取时间
128 {
129 1 uchar temp;
130 1 temp=DS1307_Read(Yearh);
131 1 str_date[0]=(temp>>4)+'0';
132 1 str_date[1]=(temp&0x0f)+'0';
133 1 temp=DS1307_Read(Year);
134 1 str_date[2]=(temp>>4)+'0';
135 1 str_date[3]=(temp&0x0f)+'0';
136 1 temp=DS1307_Read(Month);
137 1 str_date[6]=(temp>>4)+'0';
138 1 str_date[7]=(temp&0x0f)+'0';
139 1 temp=DS1307_Read(Date);
140 1 str_date[10]=(temp>>4)+'0';
141 1 str_date[11]=(temp&0x0f)+'0';
142 1
143 1 temp=DS1307_Read(Hours);
144 1 str_time[0]=(temp>>4)+'0';
145 1 str_time[1]=(temp&0x0f)+'0';
146 1 temp=DS1307_Read(Minute);
147 1 str_time[3]=(temp>>4)+'0';
148 1 str_time[4]=(temp&0x0f)+'0';
149 1 temp=DS1307_Read(Second);
150 1 RingST=temp;
151 1 str_time[6]=(temp>>4)+'0';
152 1 str_time[7]=(temp&0x0f)+'0';
153 1
154 1 temp=DS1307_Read(Day);
155 1 temp-=1;
156 1 str_day[4]=str_dayx[temp][0];
157 1 str_day[5]=str_dayx[temp][1];
158 1 }
159
160 unsigned char EditRing(unsigned char Num)
161 {
162 1 unsigned char temp,quit,m;
163 1 unsigned char Record[3]={0,0,0};
164 1 m=Read_RingTime(Num,Record);
165 1 quit=1;
166 1 while(quit)
167 1 {
168 2 while (quit==1)
169 2 {
170 3 LCD_write(0x01,COMM);
171 3 delay_ms(3);
172 3 LCD_write_string(0,0,"选择打铃类型");
173 3 LCD_write_string(0,1,"按上下键选择");
174 3 LCD_write_string(3,2,"普通");
175 3 LCD_write_string(3,3,"上课");
176 3 if (Record[2])
177 3 LCD_set_position(2,3);
178 3 else
179 3 LCD_set_position(2,2);
C51 COMPILER V7.06 MAIN 12/17/2006 14:56:13 PAGE 4
180 3 LCD_write(0x10,DATT);
181 3 key=0xff;
182 3 while(key==0xff) key=ScanKey();
183 3 if (0xff-key)
184 3 {
185 4 key_flag=1;
186 4 KeyT=0;
187 4 }
188 3 if ((key==KEY_UP)||(key==KEY_DOWN))
189 3 {
190 4 if (Record[2]) Record[2]=0;
191 4 else Record[2]=0x45;
192 4 }
193 3 else if (key==KEY_ENT) quit=2;
194 3 else if (key==KEY_ESC) quit=0;
195 3 }
196 2 temp=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -