📄 serial.lst
字号:
C51 COMPILER V7.06 SERIAL 07/23/2005 00:02:04 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE SERIAL
OBJECT MODULE PLACED IN serial.OBJ
COMPILER INVOKED BY: f:\Keil\C51\BIN\C51.EXE serial.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /* serial.H 串口初始化函数
2 建立时间 2004.7.13 最后修改时间 2004.7.13 作者:computer-lov
3 */
4
5 #include <serial.h>
*** ERROR C202 IN LINE 14 OF F:\KEIL\C51\INC\SERIAL.H: 'EA': undefined identifier
*** ERROR C202 IN LINE 15 OF F:\KEIL\C51\INC\SERIAL.H: 'TMOD': undefined identifier
*** ERROR C202 IN LINE 16 OF F:\KEIL\C51\INC\SERIAL.H: 'SCON': undefined identifier
*** ERROR C202 IN LINE 17 OF F:\KEIL\C51\INC\SERIAL.H: 'TCON': undefined identifier
*** ERROR C202 IN LINE 35 OF F:\KEIL\C51\INC\SERIAL.H: 'PCON': undefined identifier
*** ERROR C202 IN LINE 37 OF F:\KEIL\C51\INC\SERIAL.H: 'PCON': undefined identifier
*** ERROR C202 IN LINE 38 OF F:\KEIL\C51\INC\SERIAL.H: 'TH1': undefined identifier
*** ERROR C202 IN LINE 39 OF F:\KEIL\C51\INC\SERIAL.H: 'TL1': undefined identifier
*** ERROR C202 IN LINE 40 OF F:\KEIL\C51\INC\SERIAL.H: 'ES': undefined identifier
*** ERROR C202 IN LINE 41 OF F:\KEIL\C51\INC\SERIAL.H: 'TR1': undefined identifier
*** ERROR C202 IN LINE 42 OF F:\KEIL\C51\INC\SERIAL.H: 'REN': undefined identifier
*** ERROR C202 IN LINE 43 OF F:\KEIL\C51\INC\SERIAL.H: 'EA': undefined identifier
*** ERROR C202 IN LINE 49 OF F:\KEIL\C51\INC\SERIAL.H: 'EA': undefined identifier
*** ERROR C202 IN LINE 50 OF F:\KEIL\C51\INC\SERIAL.H: 'RI': undefined identifier
*** ERROR C202 IN LINE 52 OF F:\KEIL\C51\INC\SERIAL.H: 'RI': undefined identifier
*** ERROR C202 IN LINE 53 OF F:\KEIL\C51\INC\SERIAL.H: 'EA': undefined identifier
*** ERROR C202 IN LINE 54 OF F:\KEIL\C51\INC\SERIAL.H: 'SBUF': undefined identifier
*** ERROR C202 IN LINE 56 OF F:\KEIL\C51\INC\SERIAL.H: 'TI': undefined identifier
*** ERROR C202 IN LINE 57 OF F:\KEIL\C51\INC\SERIAL.H: 'SBUF': undefined identifier
*** ERROR C202 IN LINE 58 OF F:\KEIL\C51\INC\SERIAL.H: 'TI': undefined identifier
*** ERROR C202 IN LINE 59 OF F:\KEIL\C51\INC\SERIAL.H: 'TI': undefined identifier
*** ERROR C202 IN LINE 65 OF F:\KEIL\C51\INC\SERIAL.H: 'TI': undefined identifier
*** ERROR C202 IN LINE 68 OF F:\KEIL\C51\INC\SERIAL.H: 'EA': undefined identifier
*** ERROR C202 IN LINE 80 OF F:\KEIL\C51\INC\SERIAL.H: 'SBUF': undefined identifier
6 #include <hardware.h>
7
8
9 unsigned char sending;
10
11
12
13 void init_comport(unsigned int bit_rate) //串口初始化函数,使用22.1184M晶体
14 {
15 1
16 1 unsigned char temp;
17 1 EA=0;
18 1 TMOD=0x21; //定时器0工作在模式1,定时器1工作在模式2
19 1 SCON=0x50; //串口工作在模式1
20 1 TCON=0x05;
21 1 switch(bit_rate)
22 1 {
23 2 case 300: temp=0x40;break;
24 2 case 600: temp=0xA0;break;
25 2 case 1200: temp=0xD0;break;
26 2 case 2400: temp=0xE8;break;
27 2 case 4800: temp=0xF4;break;
28 2 case 9600: temp=0xF4;break;
29 2 case 11520: temp=0xF6;break;
30 2 case 12800: temp=0xF7;break;
31 2 case 14400: temp=0xF8;break;
C51 COMPILER V7.06 SERIAL 07/23/2005 00:02:04 PAGE 2
32 2 case 19200: temp=0xFA;break;
33 2 case 23040: temp=0xFB;break;
34 2 case 28800: temp=0xFC;break;
35 2 case 38400: temp=0xFD;break;
36 2 case 57600: temp=0xFE;break;
37 2 case 115200: temp=0xFF;break;
38 2 default : temp=0xF4;PCON=0x80;break;
39 2 }
40 1 if(bit_rate>4800)PCON=0x80; //串口波特率加倍
41 1 TH1=temp;
42 1 TL1=temp;
43 1 ES=1; //串行中断允许
44 1 TR1=1; //启动定时器1
45 1 REN=1; //允许接收
46 1 EA=1; //允许中断
47 1 }
*** ERROR C237 IN LINE 47 OF SERIAL.C: '_init_comport': function already has a body
48
49 //******************************* 串口中断处理 ***********************************
50 void serial_port(void) interrupt 4
51 {
52 1 EA=0;
53 1 if(RI)
54 1 {
55 2 RI=0; //表示接收到数据
56 2 EA=1;
57 2 if(SBUF=='T')
58 2 {
59 3 TI=0;
60 3 SBUF=0x41;
61 3 while(!TI);
62 3 TI=0;
63 3 }
64 2 return;
65 2 }
66 1 else
67 1 {
68 2 TI=0;
69 2 sending=0; //清正在发送标志
70 2 }
71 1 EA=1;
72 1 }
*** ERROR C237 IN LINE 72 OF SERIAL.C: 'serial_port': function already has a body
73 //*****************************************************************************************
74 void Delayms(unsigned int x)
75 {
76 1 unsigned int i;
77 1 for(;x>0;x--)
78 1 for(i=0;i<133;i++);
79 1 }
*** ERROR C237 IN LINE 79 OF SERIAL.C: '_Delayms': function already has a body
80 void send_to_comport(unsigned char temp) //往串口发送一字节数据
81 {
82 1 sending=1;
83 1 SBUF=temp;
84 1 while(sending);
85 1 Delayms(30);
86 1 }
*** ERROR C237 IN LINE 86 OF SERIAL.C: '_send_to_comport': function already has a body
87
88 void prints(unsigned char * temp,unsigned char line_feed)
89 {
C51 COMPILER V7.06 SERIAL 07/23/2005 00:02:04 PAGE 3
90 1 while((*temp)!='\0')
91 1 {
92 2 send_to_comport(*temp);
93 2 temp++;
94 2 }
95 1 if(line_feed)
96 1 {
97 2 send_to_comport(13);
98 2 send_to_comport(10);
99 2 }
100 1 }
*** ERROR C237 IN LINE 100 OF SERIAL.C: '_prints': function already has a body
101
102 void printfs(signed long int x)
103 {
104 1 signed char i;
105 1 unsigned char display_buffer[10];
106 1 display_buffer[10]=0;
107 1 if(x<0){x*=-1;send_to_comport('-');}
108 1
109 1 for(i=9;i>=0;i--)
110 1 {
111 2 display_buffer[i]='0'+x%10;
112 2 x/=10;
113 2 }
114 1 for(i=0;i<9;i++)
115 1 {
116 2 if(display_buffer[i]!='0')break;
117 2 }
118 1 for(;i<10;i++)send_to_comport(display_buffer[i]);
119 1 }
*** ERROR C237 IN LINE 119 OF SERIAL.C: '_printfs': function already has a body
120
121 void printf(unsigned long int x)
122 {
123 1 signed char i;
124 1 unsigned char display_buffer[10];
125 1 display_buffer[10]=0;
126 1 for(i=9;i>=0;i--)
127 1 {
128 2 display_buffer[i]='0'+x%10;
129 2 x/=10;
130 2 }
131 1 for(i=0;i<9;i++)
132 1 {
133 2 if(display_buffer[i]!='0')break;
134 2 }
135 1 for(;i<10;i++)send_to_comport(display_buffer[i]);
136 1 }
*** ERROR C237 IN LINE 136 OF SERIAL.C: '_printf': function already has a body
137
138 void printc(unsigned char temp)
139 {
140 1 unsigned char i,j;
141 1 i=temp;
142 1 for(j=0;j<2;j++)
143 1 {
144 2 if(!j)i>>=4;
145 2 else i=temp&0x0F;
146 2 switch(i)
147 2 {
148 3 case 0:
C51 COMPILER V7.06 SERIAL 07/23/2005 00:02:04 PAGE 4
149 3 case 1:
150 3 case 2:
151 3 case 3:
152 3 case 4:
153 3 case 5:
154 3 case 6:
155 3 case 7:
156 3 case 8:
157 3 case 9: send_to_comport(i+'0');break;
158 3 case 10: send_to_comport('A');break;
159 3 case 11: send_to_comport('B');break;
160 3 case 12: send_to_comport('C');break;
161 3 case 13: send_to_comport('D');break;
162 3 case 14: send_to_comport('E');break;
163 3 case 15: send_to_comport('F');break;
164 3 default: break;
165 3 }
166 2 }
167 1 send_to_comport(' ');
168 1 }
*** ERROR C237 IN LINE 168 OF SERIAL.C: '_printc': function already has a body
C51 COMPILATION COMPLETE. 0 WARNING(S), 32 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -