📄 main.lst
字号:
C51 COMPILER V7.06 MAIN 05/03/2008 23:24:27 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1
2 #include"reg52.h"
3 #include<intrins.h>
4 #define uchar unsigned char
5 #define uint unsigned int
6 uchar i=0;
7 uchar SHEZHI[15];
8 uchar init[7]={0x11,0x21,0x23,0x23,0x04,0x04,0x08};//秒,分,时,日,月,星期,年
9 void DISP_DATA(void);
10
11 //*******************LCD模块
12 #define LCD_DATA P0 //LCD的数据口
13
14 sbit LCD_BUSY=LCD_DATA^7; //LCD忙信号位
15
16 sbit LCD_RW=P3^5; //LCD读写控制
17 sbit LCD_RS=P3^4; //LCD寄存器选择
18 sbit LCD_EN=P3^6; //LCD使能信号
19
20 void LCD_check_busy(void) //检测LCD状态,看它是不是还在忙呢
21 {
22 1 while(1)
23 1 {
24 2 LCD_EN=0;
25 2 LCD_RS=0; //指令寄存器通信
26 2 LCD_RW=1; //read data
27 2 LCD_DATA=0xff;
28 2 LCD_EN=1;
29 2 if(!LCD_BUSY)break;
30 2 }
31 1 LCD_EN=0;
32 1 }
33
34 void LCD_cls(void) //LCD清屏
35 {
36 1
37 1 LCD_check_busy();
38 1 LCD_RS=0;
39 1 LCD_RW=0;
40 1 LCD_DATA=1;
41 1 LCD_EN=1;
42 1 LCD_EN=0;
43 1
44 1 }
45
46 void LCD_write_instruction(unsigned char LCD_instruction) //写指令到LCD
47 {
48 1 LCD_check_busy();
49 1 LCD_RS=0;
50 1 LCD_RW=0; //写数据
51 1
52 1 LCD_DATA=LCD_instruction;
53 1 LCD_EN=1;
54 1 LCD_EN=0;
55 1 }
C51 COMPILER V7.06 MAIN 05/03/2008 23:24:27 PAGE 2
56
57 void LCD_write_data(unsigned char LCD_data) //输出一个字节数据到LCD
58 {
59 1 LCD_check_busy();
60 1 LCD_RS=1;
61 1 LCD_RW=0;
62 1
63 1 LCD_DATA=LCD_data;
64 1 LCD_EN=1;
65 1 LCD_EN=0;
66 1 }
67
68 void LCD_set_position(unsigned char x) //LCD光标定位到x处
69 {
70 1 LCD_write_instruction(0x80+x);
71 1 }
72
73
74
75
76
77 void LCD_printc(unsigned char lcd_data) //输出一个字符到LCD
78 {
79 1 LCD_write_data(lcd_data);
80 1 }
81
82 void LCD_prints(unsigned char *lcd_string) //输出一个字符串到LCD
83 {
84 1 unsigned char i=0;
85 1 while(lcd_string[i]!=0x00)
86 1 {
87 2 LCD_write_data(lcd_string[i]);
88 2 i++;
89 2 }
90 1 }
91
92 void LCD_initial(void) //初始化LCD
93 {
94 1 LCD_write_instruction(0x3c);
95 1 LCD_write_instruction(0x0c);
96 1 LCD_write_instruction(0x06);//显示屏一定要不移动。
97 1 LCD_cls();
98 1 }
99 //*************************LCD模块结束
100
101 //键盘
102
103 uchar temp_OUT=0x0A;
104 uchar flag_san_key=0;
105 void delay1(void)
106 {
107 1 uint i;
108 1 for(i=300;i>0;i--);
109 1 }
110
111 void scan_key(void)
112 {
113 1 unsigned char i,temp1;
114 1 P1=0XF0;
115 1 for(i=0;i<4;i++)
116 1 {
117 2 P1=~(1<<i);
C51 COMPILER V7.06 MAIN 05/03/2008 23:24:27 PAGE 3
118 2 delay1();
119 2 temp1=P1&0xF0;
120 2 if(temp1!=0xF0)
121 2 {
122 3 delay1();
123 3 temp1=P1&0xF0;
124 3 switch(temp1)
125 3 {
126 4 case 0xe0:temp_OUT=3-(3-i)*1;SHEZHI[flag_san_key++]=temp_OUT;break; // 0 1 2 3
127 4 case 0xd0:temp_OUT=7-(3-i)*1;SHEZHI[flag_san_key++]=temp_OUT;break; // 4 5 6 7
128 4 case 0xb0:temp_OUT=11-(3-i)*1;SHEZHI[flag_san_key++]=temp_OUT;break; // 8 9 a b
129 4 case 0x70:temp_OUT=15-(3-i)*1;SHEZHI[flag_san_key++]=temp_OUT;break; // c d e f
130 4 default:break;//0x3f;
131 4 }
132 3
133 3 tt:temp1=P1&0xF0;
134 3 if(temp1!=0xF0)
135 3 {
136 4 ;
137 4 goto tt;
138 4 }
139 3 }
140 2 }
141 1 }
142
143 void DISP_DATA(void)
144 {
145 1 scan_key();
146 1 if(temp_OUT!=0X0A)
147 1 {
148 2 init[6]=(SHEZHI[0]<<4)|SHEZHI[1];
149 2 init[5]=(SHEZHI[2]<<4)|SHEZHI[3];
150 2 init[4]=(SHEZHI[4]<<4)|SHEZHI[5];
151 2 init[3]=(SHEZHI[6]<<4)|SHEZHI[7];
152 2 init[2]=(SHEZHI[8]<<4)|SHEZHI[9];
153 2 init[1]=(SHEZHI[10]<<4)|SHEZHI[11];
154 2 init[0]=(SHEZHI[12]<<4)|SHEZHI[13];
155 2
156 2 //显示
157 2 LCD_set_position(1);
158 2 LCD_printc(0X32);
159 2
160 2 LCD_set_position(2);
161 2 LCD_printc(0X30);
162 2
163 2 LCD_set_position(3);
164 2 LCD_printc(0X30+init[6]/16);
165 2
166 2 LCD_set_position(4);
167 2 LCD_printc(0X30+init[6]%16);
168 2
169 2 LCD_set_position(5);
170 2 LCD_prints(" ");
171 2 //月日
172 2
173 2 LCD_set_position(7);
174 2 LCD_printc(0X30+init[4]/16);
175 2 LCD_set_position(8);
176 2 LCD_printc(0X30+init[4]%16);
177 2
178 2 LCD_set_position(9);
179 2 LCD_prints("-");
C51 COMPILER V7.06 MAIN 05/03/2008 23:24:27 PAGE 4
180 2
181 2 LCD_set_position(10);
182 2 LCD_printc(0X30+init[3]/16);
183 2
184 2 LCD_set_position(11);
185 2 LCD_printc(0X30+init[3]%16);
186 2 LCD_set_position(12);
187 2 LCD_prints(" ");
188 2 //星期
189 2
190 2 LCD_set_position(14);
191 2 LCD_printc(0X30+init[5]%16);
192 2
193 2
194 2 //时分秒
195 2
196 2 LCD_set_position(0X4E);
197 2 LCD_printc(0X30+init[0]%16);
198 2
199 2 LCD_set_position(0X4D);
200 2 LCD_printc(0X30+init[0]/16);
201 2
202 2 LCD_set_position(0X4C);
203 2 LCD_prints(":");
204 2
205 2 LCD_set_position(0x4B);
206 2 LCD_printc(0X30+init[1]%16);
207 2
208 2 LCD_set_position(0x4a);
209 2 LCD_printc(0X30+init[1]/16);
210 2
211 2 LCD_set_position(0X49);
212 2 LCD_prints(":");
213 2
214 2 LCD_set_position(0X48);
215 2 LCD_printc(0X30+init[2]%16);
216 2 LCD_set_position(0X47);
217 2 LCD_printc(0X30+init[2]/16);
218 2
219 2 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -