📄 serial.lst
字号:
C51 COMPILER V7.20 SERIAL 03/07/2006 14:49:11 PAGE 1
C51 COMPILER V7.20, COMPILATION OF MODULE SERIAL
OBJECT MODULE PLACED IN SERIAL.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SERIAL.C OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND
line level source
1 //-----------------------------------------------------------------------------
2 // Net SERIAL.C
3 //
4 // This module handles RS-232 messages and associated tasks
5 //-----------------------------------------------------------------------------
6 #include "reg52.h"
7 #include "string.h"
8 #include "intrins.h"
9 #include "net.h"
10 #include "serial.h"
11 #include "absacc.h"
12
13 unsigned int CommRecLength;//串口接受数据长度,同时用作地址标注
14 bit CommRecFlag;//串口接收标志,接收到后置为1
15 bit CommRecBlock;
16 #define REC_BLOCK0 0x4000
17 #define REC_BLOCK1 0x5000
18
19 void init_serial(void)
20 {
21 1 SCON=0x50;//将串口设置为方式1,8位数据
22 1 PCON=0x80;//不进行2分频
23 1 TMOD=0x20;//定时器1设为模式2,
24 1 TL1=0xff;//设置波特率为57600=0xff,SMOD=1,51200=0x0,9600(TL1=0xFA,SMOD=1),5760
25 1 TH1=0xff;//设置波特率f6
26 1 PS=1;//串行中断优先级高
27 1 TR1=1;//启动定时器1
28 1
29 1 RI=0; // Clear HW_UART receive and transmit
30 1 TI=0; // complete indicators.
31 1 ES=1; // allow the serial interrupt
32 1
33 1 CommRecLength=0;
34 1 CommRecFlag=0;
35 1 CommRecBlock=0;
36 1 }
37
38 void Serial_Send_Ch(unsigned char ch)
39 {
40 1 // ES=0;
41 1 SBUF=ch;
42 1 while(!TI){}
43 1 TI=0;
44 1 // ES=1;
45 1 }
46
47 void SendCommString(unsigned char *base)
48 {
49 1 unsigned char length=strlen(base);
50 1 unsigned char i;
51 1 for(i=0;i<length;i++)Serial_Send_Ch(*(base+i));
52 1 }
53
54 void CommISR(void) interrupt 4
55 {
C51 COMPILER V7.20 SERIAL 03/07/2006 14:49:11 PAGE 2
56 1 /* if (TI)
57 1 {
58 1 return ;
59 1 }*/
60 1 if (RI)
61 1 {
62 2 RI=0;
63 2 if(CommRecBlock)XBYTE[CommRecLength+REC_BLOCK0]=SBUF;
64 2 else XBYTE[CommRecLength+REC_BLOCK1]=SBUF;
65 2 CommRecLength++;
66 2 CommRecFlag=1;
67 2 }
68 1 }
69
70 //------------------------------------------------------------------------
71 // This function converts an integer to an ASCII string. It is a
72 // normally provided as a standard library function but the Keil
73 // libraries do not include it. Caution: The string passed to this
74 // must be at least 12 bytes long
75 //------------------------------------------------------------------------
76 char * itoa(UINT value, char * buf, UCHAR radix)
77 {
78 1 UINT i;
79 1 char * ptr;
80 1 char * temphold;
81 1
82 1 temphold = buf;
83 1 ptr = buf + 12;
84 1 *--ptr = 0; // Insert NULL char
85 1 do
86 1 {
87 2 // First create string in reverse order
88 2 i = (value % radix) + 0x30;
89 2 if(i > 0x39) i += 7;
90 2 *--ptr = i;
91 2 value = value / radix;
92 2 } while(value != 0);
93 1
94 1 // Next, move the string 6 places to the left
95 1 // Include NULL character
96 1 for( ; (*buf++ = *ptr++); );
97 1 return(temphold);
98 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 312 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 2 17
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -