📄 max232.lst
字号:
C51 COMPILER V7.50 MAX232 07/31/2007 15:57:45 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MAX232
OBJECT MODULE PLACED IN MAX232.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE MAX232.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include<reg51.h>
2 #define uchar unsigned char
3 #define uint unsigned int
4 #define TR 0
5 uchar idata buf[10]={0x20,1,2,3,4,5,6,7,8,9};
6 uchar pf;
7
8
9 void init(void)
10 {TMOD=0x20; //mode 1,counter 1
11 1 TH1=0xFD; //set baud rate
12 1 TL1=0xFD;
13 1 PCON=0x00;
14 1 TR1=1; //start T/C1
15 1 SCON=0x50; //mode1
16 1 }
17
18
19 void send(uchar idata *d)
20 {uint i;
21 1 uchar j,v;
22 1 P1=0Xfb;
23 1 do{RI=0;
24 2 SBUF=0xaa; //send handshaking message
25 2 while (TI==0); //sending
26 2 TI=0; //software clear
27 2 while(RI==0); //waiting for ACK
28 2 RI=0;
29 2 v=SBUF; //software clear
30 2 }while (v!=0xbb);//B is not ready
31 1 do{
32 2 pf=0; //clear the sum
33 2 for(i=0;i<10;i++){
34 3 j=*(d+i);
35 3 SBUF=j ; //send the data
36 3 pf+=*(d+i); //sum
37 3 while(TI==0);TI=0;
38 3 }
39 2 SBUF=pf; //send sum
40 2 while(TI==0);TI=0;
41 2 while(RI==0);RI=0; //waiting for B to ack
42 2 }while (SBUF!=0); //if there is wrong, send again
43 1 }
44
45 void receive(uchar idata *d)
46 {uchar i;
47 1 do{
48 2 while(RI==0);RI=0;
49 2 } while((SBUF^0xaa)!=0); //check if A is sending
50 1 SBUF=0xbb; //send ACK
51 1 while(TI==0);TI=0;
52 1 while(1){
53 2 pf=0;
54 2 for(i=0;i<16;i++){
55 3 while(RI==0);RI=0;
C51 COMPILER V7.50 MAX232 07/31/2007 15:57:45 PAGE 2
56 3 d[i]=SBUF; //receive data
57 3 pf+=d[i]; //sum
58 3 }
59 2 while (RI==0);RI=0; //receive sum
60 2 if((SBUF^pf)==0){ //check sum
61 3 SBUF=0x00;break;} //if the two are equal, then send 00
62 2 else{
63 3 SBUF=0xff; //send FF,receive again
64 3 while(TI==0);TI=0;
65 3 }
66 2 }
67 1
68 1 }
69
70 void main(void){
71 1 init();
72 1 if(TR==0){
73 2 send(buf);
74 2 }
75 1 //else{
76 1 //receive(buf);
77 1 //}
78 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 164 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = 10 ----
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 + -