?? test.lst
字號:
C51 COMPILER V8.08 TEST 03/10/2009 09:33:40 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE TEST
OBJECT MODULE PLACED IN test.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE test.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /***************************************************************/
2 /******** Program Description : Prepaid Energy Meter Program ***/
3 /***************** Programmer : Amit Kumar Das *****************/
4 /*************** Program Date : 26th December 2008 *************/
5 /*************** Program Time : 08:58 AM ***********************/
6 /************ Microcontroller : AT89C52 ************************/
7 /******** Operating Frequency : 12.0MHz ************************/
8 /***************************************************************/
9
10 #include <reg51.h>
11 #include <string.h>
12
13 sbit rs = P2^7; // declare P2.7 as rs pin
14 sbit en = P2^5; // declare p2.5 as enable pin
15 sbit rw = P2^6; // declare p2.6 as read/write pin
16 sbit b = P0^7; // busy flag
17 sbit X1 = P3^5; // interrupt input for pulse counting
18 sbit outbit = P3^0; // ouput for relay
19
20 void writecmd(unsigned char a); // function to send command to LCD
21 void writedat(unsigned char b); // function to send data to LCD
22 void busy(); // function to check LCD is busy or not
23 void writestr(unsigned char *s); // function to write string on LCD
24 void MSDelay(unsigned int); // delay function
25
26 void writecmd(unsigned char a)
27 {
28 1 busy(); // check for LCD is busy or not
29 1 rs = 0; // clear rs pin for command
30 1 rw = 0; // clear rw pin to write
31 1 P0 = a; // send command character
32 1 en = 1; // strob LCD
33 1 en = 0;
34 1 }
35 void writedat(unsigned char b)
36 {
37 1 busy(); // check for LCD is busy or not
38 1 rs = 1; // set rs pin for data
39 1 rw = 0; // clear rw pin to write
40 1 P0 = b; // send data character
41 1 en = 1; // strob LCD
42 1 en = 0;
43 1 }
44 void busy()
45 {
46 1 en = 0; // disable display
47 1 P0 = 0xFF; // configur P0 as input
48 1 rs = 0; // clear rs pin for command
49 1 rw = 1; // set rw pin to read
50 1 while(b==1)
51 1 {
52 2 en=0; // strob LCD till P0.7 is 1
53 2 en=1;
54 2 }
55 1 en=0;
C51 COMPILER V8.08 TEST 03/10/2009 09:33:40 PAGE 2
56 1 }
57 void writestr(unsigned char *s)
58 {
59 1 unsigned char l,i;
60 1 l = strlen(s); // get the length of string
61 1 for(i=1;i<l;i++)
62 1 {
63 2 writedat(*s); // write every char one by one
64 2 s++;
65 2 }
66 1 }
67
68 void MSDelay(unsigned int itime)
69
70 {
71 1 unsigned int i,j;
72 1 for(i=0;i<itime;i++)
73 1 for(j=0;j<1275;j++);
74 1 }
75
76 void main(void)
77
78 {
79 1 P0=0x00; // P0 and P2 as output ports
80 1 P2=0x00; // LCD controls output
81 1 P1=0xFF; // input for card data(currency)
82 1 X1=1; // interrupt input for pulse counting
83 1 outbit=0x00; // output for relay
84 1 writecmd(0x38); // initialize 5X7 matrix LCD
85 1 writecmd(0x0E);
86 1 writecmd(0x82); // move cursor to first line 2nd pos
87 1 writecmd(0x01); // clear memory and home cursor
88 1 writestr("Prepaid Energy "); // write message in first line
89 1 writecmd(0xC4); // move cursor to second line 4th pos
90 1 writestr("Meter ");
91 1 MSDelay(500);
92 1 here: writecmd(0x01);
93 1 writecmd(0x82);
94 1 writestr("Please Insert ");
95 1 writecmd(0xC7);
96 1 writestr("Card ");
97 1
98 1 if(P1==0x01)
99 1
100 1 {
101 2 writecmd(0x01);
102 2 writecmd(0x83);
103 2 writestr("Card Found ");
104 2 writecmd(0xC3);
105 2 writestr("Value = 10 Rs. ");
106 2 MSDelay(500);
107 2 outbit=0xFF;
108 2 TMOD=0x60;
109 2 TH1=250;
110 2 TL1=250;
111 2 TR1=1;
112 2 while(TF1==0); // wait for timer overflow
113 2 TR1=0;
114 2 TF1=0;
115 2 writecmd(0x01);
116 2 writecmd(0x81);
117 2 writestr("Used : 1 Unit ");
C51 COMPILER V8.08 TEST 03/10/2009 09:33:40 PAGE 3
118 2 writecmd(0xC2);
119 2 writestr("BAL = 9 Rs ");
120 2 TMOD=0x60;
121 2 TH1=250;
122 2 TR1=1;
123 2 while(TF1==0); // wait for timer overflow
124 2 TR1=0;
125 2 TF1=0;
126 2 writecmd(0x01);
127 2 writecmd(0x81);
128 2 writestr("Used : 2 Units ");
129 2 writecmd(0xC2);
130 2 writestr("BAL = 8 Rs ");
131 2 TMOD=0x60;
132 2 TH1=250;
133 2 TR1=1;
134 2 while(TF1==0); // wait for timer overflow
135 2 TR1=0;
136 2 TF1=0;
137 2 writecmd(0x01);
138 2 writecmd(0x81);
139 2 writestr("Used : 3 Units ");
140 2 writecmd(0xC2);
141 2 writestr("BAL = 7 Rs ");
142 2 TMOD=0x60;
143 2 TH1=250;
144 2 TR1=1;
145 2 while(TF1==0); // wait for timer overflow
146 2 TR1=0;
147 2 TF1=0;
148 2 writecmd(0x01);
149 2 writecmd(0x81);
150 2 writestr("Used : 4 Units ");
151 2 writecmd(0xC2);
152 2 writestr("BAL = 6 Rs ");
153 2 TMOD=0x60;
154 2 TH1=250;
155 2 TR1=1;
156 2 while(TF1==0); // wait for timer overflow
157 2 TR1=0;
158 2 TF1=0;
159 2 writecmd(0x01);
160 2 writecmd(0x81);
161 2 writestr("Used : 5 Units ");
162 2 writecmd(0xC2);
163 2 writestr("BAL = 5 Rs ");
164 2 TMOD=0x60;
165 2 TH1=250;
166 2 TR1=1;
167 2 while(TF1==0); // wait for timer overflow
168 2 TR1=0;
169 2 TF1=0;
170 2 writecmd(0x01);
171 2 writecmd(0x81);
172 2 writestr("Used : 6 Units ");
173 2 writecmd(0xC2);
174 2 writestr("BAL = 4 Rs ");
175 2 TMOD=0x60;
176 2 TH1=250;
177 2 TR1=1;
178 2 while(TF1==0); // wait for timer overflow
179 2 TR1=0;
C51 COMPILER V8.08 TEST 03/10/2009 09:33:40 PAGE 4
180 2 TF1=0;
181 2 writecmd(0x01);
182 2 writecmd(0x81);
183 2 writestr("Used : 7 Units ");
184 2 writecmd(0xC2);
185 2 writestr("BAL = 3 Rs ");
186 2 TMOD=0x60;
187 2 TH1=250;
188 2 TR1=1;
189 2 while(TF1==0); // wait for timer overflow
190 2 TR1=0;
191 2 TF1=0;
192 2 writecmd(0x01);
193 2 writecmd(0x81);
194 2 writestr("Used : 8 Units ");
195 2 writecmd(0xC2);
196 2 writestr("BAL = 2 Rs ");
197 2 TMOD=0x60;
198 2 TH1=250;
199 2 TR1=1;
200 2 while(TF1==0); // wait for timer overflow
201 2 TR1=0;
202 2 TF1=0;
203 2 writecmd(0x01);
204 2 writecmd(0x81);
205 2 writestr("Used : 9 Units ");
206 2 writecmd(0xC2);
207 2 writestr("BAL = 1 Rs ");
208 2 TMOD=0x60;
209 2 TH1=250;
210 2 TR1=1;
211 2 while(TF1==0); // wait for timer overflow
212 2 TR1=0;
213 2 TF1=0;
214 2 writecmd(0x01);
215 2 writecmd(0x81);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -