📄 lcd.lst
字号:
C51 COMPILER V7.08 LCD 05/26/2008 00:03:31 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\c51.exe lcd.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND CODE
line level source
1 #include <reg52.h>
2 #include <stdlib.h>
3 #include <intrins.h>
4 #include <stdio.h>
5 #define TIMER0_COUNT 0xFE33
6 #define uchar unsigned char
7 #define uint unsigned int
8 unsigned char count_min_1=0;
9 unsigned char count_min_2=0;
10 unsigned char count_hour_1=0;
11 unsigned char count_hour_2=0;
12 uchar KEY,timer0_tick=0;
13 uint a;
14 /********************引脚定义********************/
15 sbit RS =P2^5; //数据指令
16 sbit RW =P2^6; //读写
17 sbit E =P2^7; //使能
18 sbit CS1 =P2^3; //左片选
19 sbit CS2 =P2^4; //中片选
20 sbit RST =P2^2; //右片选
21
22 sbit KEY_YES =P2^0; //YES
23 sbit KEY_NO =P2^1; //NO
24 sbit KEY_UP =P3^4; //UP
25 sbit KEY_DOWN =P3^5; //DOWN
26
27 unsigned char Page; //页 地址
28 unsigned char Col; //列 地址
29
30 unsigned char code BMP0[]; //启动界面
31 unsigned char code BMP1[]; //选择界面
32 unsigned char code BMP2[]; //帐户信息界面
33 unsigned char code BMP3[]; //公司联系方式
34 unsigned char code BMP4[]; //公司简介
35 unsigned char code BMP5[];
36 unsigned char code Cursor[]; //光标
37 unsigned char code number_0[];
38 unsigned char code number_1[];
39 unsigned char code number_2[];
40 unsigned char code number_3[];
41 unsigned char code number_4[];
42 unsigned char code number_5[];
43 unsigned char code number_6[];
44 unsigned char code number_7[];
45 unsigned char code number_8[];
46 unsigned char code number_9[];
47 unsigned char code Company_Profile[]; /*-- 文字: 公司简介 --*/
48 unsigned char code Information[]; /*-- 文字: 信息查询 --*/
49 unsigned char code parameters[]; /*-- 文字: 参数设置 --*/
50 unsigned char code Contact[]; /*-- 文字: 联系方式 --*/
51 unsigned char code Symbol[]; /*-- 文字: : --*/
52
53 unsigned char code DATE[];
54 unsigned char code TIME[];
55
C51 COMPILER V7.08 LCD 05/26/2008 00:03:31 PAGE 2
56 void Delay(unsigned int MS);
57 void wtcom(void);
58 void time_display(void)
59 {
60 1
61 1 if(timer0_tick==60)
62 1 {
63 2 timer0_tick=0;
64 2 count_min_1+=1;
65 2 if(count_min_1==10)
66 2 {
67 3 count_min_1=0;
68 3 count_min_2+=1;
69 3 if(count_min_2==6)
70 3 {
71 4 count_min_2=0;
72 4 count_hour_1+=1;
73 4 if(count_hour_1==10)
74 4 {
75 5 count_hour_1=0;
76 5 count_hour_2+=1;
77 5 if(count_hour_2==2)count_hour_2=0;
78 5 }
79 4 }
80 3 }
81 2
82 2 }
83 1 }
84 /***************************************************
85 定时器服务程序
86 ***************************************************/
87 static void timer0_isr(void) interrupt 1 using 0
88 {
89 1 TR0=0;
90 1 TL0=(TIMER0_COUNT&0x00FF);
91 1 TH0=(TIMER0_COUNT>>8);
92 1 TR0=1;
93 1 timer0_tick++;
94 1 }
95 /***************************************************
96 定时器初始化程序
97 ***************************************************/
98 static void timer0_initialize(void)
99 {
100 1 EA=0;
101 1 timer0_tick=0;
102 1 TR0=0;
103 1 TMOD=0x01;
104 1 TL0=(TIMER0_COUNT&0x00FF);
105 1 TH0=(TIMER0_COUNT >> 8);
106 1 PT0=0;
107 1 ET0=1;
108 1 TR0=1;
109 1 EA=1;
110 1 }
111
112 /***************************/
113 /*检查Busy */
114 /***************************/
115 void BusyL(void)
116 {
117 1 CS1= 0;
C51 COMPILER V7.08 LCD 05/26/2008 00:03:31 PAGE 3
118 1 CS2= 0;
119 1 wtcom();
120 1 }
121
122 void BusyM(void)
123 {
124 1 CS1= 0;
125 1 CS2= 1;
126 1 wtcom();
127 1 }
128
129 void BusyR(void)
130 {
131 1 CS1= 1;
132 1 CS2= 0;
133 1 wtcom();
134 1 }
135 void wtcom(void)
136 {
137 1 RS = 0; //指令
138 1 RW = 1;
139 1 P0 = 0xFF; //输出0xff以便读取正确
140 1 E = 1;
141 1 _nop_();
142 1 while(P0&0x80); //Status Read Bit7 = BUSY
143 1 E = 0;
144 1 _nop_();
145 1 }
146 /********************************************************/
147 /*根据设定的坐标数据,定位LCM上的下一个操作单元位置 */
148 /********************************************************/
149 void Locatexy(void)
150 {
151 1 unsigned char x,y;
152 1 switch (Col&0xc0) /* col.and.0xC0 */
153 1 { /*条件分支执行 */
154 2 case 0: {BusyL();break;}/*左区 */
155 2 case 0x40: {BusyM();break;}/*中区 */
156 2 case 0x80: {BusyR();break;}/*右区 */
157 2 }
158 1 x = Col&0x3F|0x40; /* col.and.0x3f.or.Set Y Address 相当于x = (Col&0x3F)|0x40;*/
159 1 y = Page&0x07|0xB8; /* row.and.0x07.or.set Page */
160 1
161 1 wtcom(); /* waitting for enable */
162 1 RS = 0; //指令
163 1 RW = 0; //写
164 1 P0 = y; //设置页面地址
165 1 E = 1;
166 1 _nop_();
167 1 E = 0;
168 1 _nop_();
169 1
170 1 wtcom(); /* waitting for enable */
171 1 RS = 0;
172 1 RW = 0;
173 1 P0 = x; //设置列地址
174 1 E = 1;
175 1 _nop_();
176 1 E = 0;
177 1 _nop_();
178 1 }
179
C51 COMPILER V7.08 LCD 05/26/2008 00:03:31 PAGE 4
180 /***************************/
181 /*写指令 */
182 /***************************/
183 void WriteCommandL( unsigned char CommandByte )
184 {
185 1 BusyL();
186 1 P0 = CommandByte;
187 1 RS = 0; //指令
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -