📄 计价器.lst
字号:
C51 COMPILER V8.02 计价芲 04/12/2007 08:50:21 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE 计价芲
OBJECT MODULE PLACED IN 计价器.OBJ
COMPILER INVOKED BY: d:\Keil 8\C51\BIN\C51.EXE 计价器.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <AT89X51.H>
2 #include<intrins.h>
3
4 #define uchar unsigned char
5 #define uint unsigned int
6 #define addwr 0xa0
7 #define addrd 0xa1
8
9 unsigned char code duanma[]={0x3f,0x06,0x5b,0x4f, //定义段码
10 0x66,0x6d,0x7d,0x07,
11 0x7f,0x6f,0x77,0x7c,
12 0x39,0x5e,0x79,0x71,
13 0x40,0x00,0xbf,0x86,
14 0xdb,0xcf,0xe6,0xed,
15 0xfd,0x87,0xff,0xef};
16 unsigned char weima[]={0xfe,0xfd,0xfb,0xf7, //定义扫描位码
17 0xef,0xdf,0xbf,0x7f};
18 unsigned char shijian[8]={0,0,16,0,0,16,0,0}; //时间存储单元
19 unsigned char lucheng[8]={0,0,18,0,16,0,18,0}; //路程存储单元
20 char jiage[8]={2,19,17,0,19,17,5,20} ; //价格存储单元
21 unsigned char zongjia[8]={0,18,17,17,17,0,18,0} ; //总价存储单元
22 char mima[8]={16,16,16,16,16,16,16,16} ; //输密码存储单元
23 unsigned char mima1[8]={1,2,3,4,5,6,7,8}; //原始密码存储单元
24 unsigned char lu,x,y,cuo=0,hour1,w=0,m=0,n; //定义相关变量
25 int i;
26 unsigned char dis;
27 char second;
28 char minite,minite2;
29 char hour;
30 unsigned int tcnt,tcnt2;
31 unsigned char ms,a,c,jia;
32
33 sbit k0=P1^0;
34 sbit k1=P1^1;
35 sbit k2=P1^2;
36 sbit k3=P1^3;
37 sbit sda=P1^7;
38 sbit scl=P1^6;
39 sbit wp=P1^5;
40 sbit led=P1^4;
41 bit k=0;
42
43 delay(int t) //延时子程序
44 {
45 1 int s,e;
46 1 for(s=0;s<t;s++)
47 1 for(e=0;e<100;e++);
48 1 }
49
50 void mdelay(uchar j)
51 {
52 1 uint i;
53 1 for(;j>0;j--)
54 1 {
55 2 for(i=0;i<125;i--)
C51 COMPILER V8.02 计价芲 04/12/2007 08:50:21 PAGE 2
56 2 {;}
57 2 }
58 1 }
59
60 void start(void)
61 {
62 1 sda=1;
63 1 scl=1;
64 1 _nop_();_nop_();_nop_();_nop_();
65 1 sda=0;
66 1 _nop_();_nop_();_nop_();_nop_();
67 1 }
68
69 void stop(void)
70 {
71 1 sda=0;
72 1 scl=1;
73 1 _nop_();_nop_();_nop_();_nop_();
74 1 sda=1;
75 1 _nop_();_nop_();_nop_();_nop_();
76 1
77 1 }
78
79 void ack(void)
80 {
81 1 sda=0;
82 1 _nop_();_nop_();_nop_();_nop_();
83 1 scl=1;
84 1 _nop_();_nop_();_nop_();_nop_();
85 1 scl=0;
86 1 }
87
88 void noack(void)
89 {
90 1 sda=1;
91 1 _nop_();_nop_();_nop_();_nop_();
92 1 scl=1;
93 1 _nop_();_nop_();_nop_();_nop_();
94 1 scl=0;
95 1 }
96
97 void send(uchar Data)
98 {
99 1 uchar bitcounter=8;
100 1 uchar temp;
101 1 do
102 1 {
103 2 temp=Data;
104 2 scl=0;
105 2 _nop_();_nop_();_nop_();_nop_();
106 2 if((temp&0x80)==0x80)
107 2 sda=1;
108 2 else
109 2 sda=0;
110 2 scl=1;
111 2 temp=Data<<1;
112 2 Data=temp;
113 2 bitcounter--;
114 2 }while(bitcounter);
115 1 scl=0;
116 1 }
117
C51 COMPILER V8.02 计价芲 04/12/2007 08:50:21 PAGE 3
118 uchar read(void)
119 {
120 1 uchar temp=0;
121 1 uchar temp1=0;
122 1 uchar bitcounter=8;
123 1 sda=1;
124 1 do
125 1 {
126 2 scl=0;
127 2 _nop_();_nop_();_nop_();_nop_();
128 2 scl=1;
129 2 _nop_();_nop_();_nop_();_nop_();
130 2 if(sda)
131 2 temp=temp|0x01;
132 2 else
133 2 temp=temp&0xfe;
134 2 if(bitcounter-1)
135 2 {
136 3 temp1=temp<<1;
137 3 temp=temp1;
138 3 }
139 2 bitcounter--;
140 2 }while(bitcounter);
141 1 return(temp);
142 1 }
143
144 void wrtorom(uchar Data[],uchar address,uchar num)
145 {
146 1 uchar i;
147 1 uchar *pData;
148 1 pData=Data;
149 1 for(i=0;i<num;i++)
150 1 {
151 2 start();
152 2 send(0xa0);
153 2 ack();
154 2 send(address+i);
155 2 ack();
156 2 send(*(pData+i));
157 2 ack();
158 2 stop();
159 2 mdelay(20);
160 2 }
161 1 }
162
163 void rdfromrom(uchar Data[],uchar address,uchar num)
164 {
165 1 uchar i;
166 1 uchar *pData;
167 1 pData=Data;
168 1 for(i=0;i<num;i++)
169 1 {
170 2 start();
171 2 send(0xa0);
172 2 ack();
173 2 send(address+i);
174 2 ack();
175 2 start();
176 2 send(0xa1);
177 2 ack();
178 2 *(pData+i)=read();
179 2 scl=0;
C51 COMPILER V8.02 计价芲 04/12/2007 08:50:21 PAGE 4
180 2 noack();
181 2 stop();
182 2 }
183 1 }
184
185 yijian() //一键是否按下子程序
186 {
187 1 char q=0;
188 1 if(k0==0)
189 1 {
190 2 delay(2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -