📄 ht1621.lst
字号:
C51 COMPILER V7.08 HT1621 12/13/2006 10:02:44 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE HT1621
OBJECT MODULE PLACED IN HT1621.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE HT1621.C BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************
2 编制时间:2006.10.28
3 编制人:梁香勇
4 编制目的:测试笔段型模块
5 程序应用功能:现在能应用与ES019004/ES02500,可用于ES025004G的按钮测试4
6 应用IC:HT162
7 *******************************************************************/
8 #include <AT89X51.h>
9 #include <Intrins.h>
10 #define CS P3_2 // Chip Selection (Low Effective)
11 #define SDA P3_0 // Data I/O
12 #define SCK P3_1 // Write Clock Input (0 to 1)(4us Tclk is needed)
13 sbit K2switch = P3^3;
14 sbit K1switch = P3^4;
15 #define seg 32
16 void delay4us(void); // Delay 4us
17 void UsTime(unsigned char i);
18 void SetMode(unsigned char ICMode);
19 void delay100ms(void);
20 void delay500ms(void);
21 void delay1s(void); // Delay 1 second
22 void display(unsigned char *pdbbit);
23 code unsigned char wcd1[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf
-f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
24 code unsigned char wcd2[]={ 0x00,0x07,0x0f,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x0e,0x0e,0x0f,0x0e,0x0f,0x0
-e,0x0f,0x0e,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x07,0x0f,0x07,0x00,0x0f,0x00 };
25 code unsigned char wcd3[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
-0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
26 code unsigned char wcd4[]={ 0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0
-e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e };
27 //==================================================
28 //延时微秒
29 //==================================================
30
31 void Delay_us(unsigned char us)
32 {
33 1 unsigned char j;
34 1 for(j=0;j<us;j++)
35 1 _nop_();
36 1 }
37
38 // Delay microsecond larger than 400us
39 void DelayUs(unsigned int Tus)
40 {
41 1 Tus = Tus - 135;
42 1 Tus = (Tus - 9)/11;
43 1 while (--Tus >0);
44 1 }
45
46 void delay4us(void)
47 {
48 1 // 4us delay
49 1 }
50
51 // Delay microsecond less than 255us
C51 COMPILER V7.08 HT1621 12/13/2006 10:02:44 PAGE 2
52 void UsTime(unsigned char i)
53 {
54 1 i=i/2-5;
55 1 while(--i!=0);
56 1 }
57
58 void delay100ms(void)
59 {
60 1 unsigned char i;
61 1 for (i = 0 ; i < 2 ; i++)
62 1 {
63 2 DelayUs(25000);
64 2 }
65 1 }
66 void delay500ms(void)
67 {
68 1 unsigned char i;
69 1 for (i = 0 ; i < 10 ; i++)
70 1 {
71 2 DelayUs(50000);
72 2 }
73 1 }
74 void delay1s(void)
75 {
76 1 unsigned char i;
77 1 for (i = 0 ; i < 20 ; i++)
78 1 {
79 2 DelayUs(50000);
80 2 }
81 1 }
82
83 void SetCA(unsigned char Addr)
84 {
85 1 unsigned char i;
86 1 SetMode(0xA0);
87 1 for (i = 0; i < 6; i++)
88 1 {
89 2 SCK = 0;
90 2 SDA = (Addr << (i + 2)) & 0x80;
91 2 SCK = 1;
92 2 }
93 1 }
94
95
96
97 void SetMode(unsigned char ICMode)
98 {
99 1 unsigned char i;
100 1 CS = 0;
101 1 CS = 1;
102 1 delay4us();
103 1 CS = 0;
104 1 for (i = 0; i < 3; i++)
105 1 {
106 2 SCK = 0;
107 2 SDA = (ICMode << i) & 0x80;
108 2 SCK = 1;
109 2 }
110 1 }
111
112 // Send a command to the IC
113 void SendCmd(unsigned char Command)
C51 COMPILER V7.08 HT1621 12/13/2006 10:02:44 PAGE 3
114 {
115 1 // 9 bits total
116 1 unsigned char i;
117 1 for (i = 0; i < 9; i++)
118 1 {
119 2 SCK = 0;
120 2 SDA = (Command << i) & 0x80;
121 2 SCK = 1;
122 2 }
123 1 }
124
125
126 void WriteData(unsigned char dByte)
127 {
128 1 unsigned char i;
129 1 for (i = 0; i < 4; i++)
130 1 { if(K1switch==1)
131 2 {
132 3 if(K1switch==1)
133 3 {Delay_us(5);
134 4 for(;;)
135 4 { if(K2switch==1)
136 5 { Delay_us(5);
137 6 if(K2switch==1)
138 6 return;
139 6 }
140 5 }
141 4 }
142 3 // Delay_1s();
143 3 // Delay_1s();
144 3 // Delay_1s();
145 3 // Delay_1s();
146 3 }
147 2 else
148 2 {
149 3 SCK = 0;
150 3 SDA = (dByte >> i) & 0x01;
151 3 SCK = 1;
152 3 }
153 2 }
154 1 }
155 //***********************************************
156 //普通扫描
157 //**********************************************
158 void display(unsigned char *pdbbit)
159 {
160 1 unsigned char m;
161 1 SetCA(0);
162 1 for(m=0; m < seg; m++)
163 1 {
164 2 WriteData(pdbbit[m]);
165 2 delay100ms();
166 2 //delay100ms();
167 2 }
168 1
169 1 }
170 //***********************************************
171 //快速扫描
172 //**********************************************
173 void displayL(unsigned char *pdbbit)
174 {
175 1 unsigned char m;
C51 COMPILER V7.08 HT1621 12/13/2006 10:02:44 PAGE 4
176 1 SetCA(0);
177 1 for(m=0; m < seg; m++)
178 1 {
179 2 WriteData(pdbbit[m]);
180 2 //delay100ms();
181 2 //delay100ms();
182 2 }
183 1
184 1 }
185 //clear all display
186 void clear(void)
187 {
188 1 unsigned char n;
189 1 SetCA(0);
190 1 for(n=0; n < seg; n++)
191 1 {
192 2 WriteData(0x00);
193 2
194 2 }
195 1
196 1 }
197
198
199
200 // LCD Initialization
201 void LCD_Init(void)
202 {
203 1 SetMode(0x80);
204 1 SendCmd(0x01);
205 1 SendCmd(0x18);
206 1 SendCmd(0x29);
207 1 SendCmd(0x03);
208 1 }
209
210 void main(void)
211 {
212 1 //P3=0;
213 1 K2switch=0;
214 1 K1switch=0;
215 1 LCD_Init();
216 1 clear();
217 1 while(1)
218 1 {
219 2
220 2 displayL(wcd1);
221 2 delay500ms();
222 2 delay500ms();
223 2
224 2 display(wcd3);
225 2 delay500ms();
226 2
227 2 // display(wcd1);
228 2 // delay500ms();
229 2 // delay500ms();
230 2 displayL(wcd1);
231 2 delay500ms();
232 2 delay500ms();
233 2
234 2 display(wcd3);
235 2 delay500ms();
236 2 // delay500ms();
237 2
C51 COMPILER V7.08 HT1621 12/13/2006 10:02:44 PAGE 5
238 2 // display(wcd1);
239 2 // delay500ms();
240 2
241 2 // display(wcd3);
242 2 // delay500ms();
243 2
244 2 }
245 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 409 ----
CONSTANT SIZE = 129 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 8
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -