?? ex.lst
字號:
C51 COMPILER V8.02 EX 10/16/2008 21:31:20 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE EX
OBJECT MODULE PLACED IN ex.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ex.c BROWSE DEBUG OBJECTEXTEND
line level source
1 //****************Copyright (c)*************
2 // 成都麟鑫科技有限責任公司
3 // http://www.linxinpro.com
4 //******************************************
5 #include<reg51.h>
6 sbit rs = P3^6;
7 sbit e = P3^7;
8 sbit beep=P1^4;
9 sbit RECIVE=P3^2;
10 void isend(unsigned char adr);
11 void dsend(unsigned char asc);
12 void xianshi(unsigned char xx1,unsigned char xx2,unsigned char xx3,unsigned char xx4);
13 void delay(unsigned int count);
14 void delaycl(void);
15 void delaycp(void);
16 void jieshou(void);
17 unsigned char getbyte[4];
18 //------------------------------------------
19 void main(void)
20 {
21 1 P2=0XFF;
22 1 getbyte[0]=0;
23 1 getbyte[1]=0;
24 1 getbyte[2]=0;
25 1 getbyte[3]=0;
26 1 xianshi(getbyte[0],getbyte[1],getbyte[2],getbyte[3]);
27 1 while(1)
28 1 jieshou();
29 1 }
30 //-------------------------------------------
31 void isend(unsigned char adr)
32 {
33 1 P2=255;
34 1 rs=0;
35 1 e=1;
36 1 P2=adr;
37 1 e=0;
38 1 delaycp();
39 1 }
40 //-------------------------------------------
41 void dsend(unsigned char asc)
42 {
43 1 P2=255;
44 1 rs=1;
45 1 e=1;
46 1 P2=asc;
47 1 e=0;
48 1 delaycl();
49 1 }
50 //--------------------------------------------
51 void jieshou(void)
52 {
53 1 unsigned int loops;
54 1 unsigned char ritbits;
55 1 unsigned char getbit;
C51 COMPILER V8.02 EX 10/16/2008 21:31:20 PAGE 2
56 1 unsigned int excount;
57 1 excount=0x0000;
58 1 while(RECIVE==1)
59 1 {
60 2 excount++;
61 2 if(excount>=500)
62 2 goto exits;
63 2 }
64 1 for (loops=0;loops<=32;loops++)
65 1 { //檢查8ms的低電平
66 2 delay(10);
67 2 if(RECIVE==1)
68 2 goto exits;
69 2 }
70 1 excount=0x0000;
71 1 while(RECIVE==0)
72 1 {
73 2 excount++;
74 2 if(excount>=500)
75 2 goto exits;
76 2 }
77 1 while(RECIVE==0);
78 1 delay(45);
79 1 if(RECIVE==1)
80 1 goto exits;
81 1 excount=0x0000;
82 1 while(RECIVE==1)
83 1 {
84 2 excount++;
85 2 if(excount>=500)
86 2 goto exits;
87 2 }
88 1 while(RECIVE==1);
89 1 for (ritbits=0;ritbits<=3;ritbits++)
90 1 {
91 2 getbyte[ritbits]=0X00;
92 2 for (loops=1;loops<=8;loops++)
93 2 {
94 3 excount=0x0000;
95 3 while(RECIVE==0)
96 3 {
97 4 excount++;
98 4 if(excount>=500)
99 4 goto exits;
100 4 }
101 3 delay(45); //跳過550個uS的電平
102 3 if(RECIVE==1)
103 3 getbit=0x01;
104 3 else
105 3 getbit=0x00;
106 3 getbyte[ritbits]=getbyte[ritbits]<<1;
107 3 getbyte[ritbits]=getbyte[ritbits] | getbit;
108 3 excount=0x0000;
109 3 while(RECIVE==1)
110 3 {
111 4 excount++;
112 4 if(excount>=500)
113 4 goto exits;
114 4 }
115 3 }
116 2 }
117 1 beep=0;
C51 COMPILER V8.02 EX 10/16/2008 21:31:20 PAGE 3
118 1 xianshi(getbyte[0],getbyte[1],getbyte[2],getbyte[3]);
119 1 delay(50);
120 1 beep=1;
121 1 exits:
122 1 getbyte[0]=0x00;
123 1 }
124 //--------------------------------------------
125 void xianshi(unsigned char xx1,unsigned char xx2,unsigned char xx3,unsigned char xx4)
126 {
127 1 unsigned int sx5;
128 1 unsigned int sx4;
129 1 sx5=xx1/10;
130 1 sx4=sx5/10;
131 1 isend(1);
132 1 isend(56);
133 1 isend(12);
134 1 isend(128);
135 1 dsend(sx4+48);
136 1 dsend(sx5-sx4*10+48);
137 1 dsend(xx1-sx5*10+48);
138 1 dsend(32);
139 1 sx5=xx2/10;
140 1 sx4=sx5/10;
141 1 dsend(sx4+48);
142 1 dsend(sx5-sx4*10+48);
143 1 dsend(xx2-sx5*10+48);
144 1 dsend(32);
145 1 sx5=xx3/10;
146 1 sx4=sx5/10;
147 1 dsend(sx4+48);
148 1 dsend(sx5-sx4*10+48);
149 1 dsend(xx3-sx5*10+48);
150 1 dsend(32);
151 1 sx5=xx4/10;
152 1 sx4=sx5/10;
153 1 dsend(sx4+48);
154 1 dsend(sx5-sx4*10+48);
155 1 dsend(xx4-sx5*10+48);
156 1 dsend(32);
157 1 }
158 //--------------------------------------------
159 void delay(unsigned int count)
160 {
161 1 unsigned int iu;
162 1 for(iu=0;iu<=count;iu++);
163 1 }
164 void delaycl()
165 {
166 1 unsigned int j;
167 1 for (j=0;j<1100;j++);
168 1 }
169 //--------------------------------------------
170 void delaycp()
171 {
172 1 unsigned int i;
173 1 for(i=0;i<220;i++);
174 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 656 ----
CONSTANT SIZE = ---- ----
C51 COMPILER V8.02 EX 10/16/2008 21:31:20 PAGE 4
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 4 14
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 + -