📄 example.lst
字号:
C51 COMPILER V8.02 EXAMPLE 08/16/2008 17:20:01 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE EXAMPLE
OBJECT MODULE PLACED IN Example.OBJ
COMPILER INVOKED BY: E:\KeilC应用程序\C51\BIN\C51.EXE Example.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg51.h>
2 #include <string.h>
3 #include"lcd.h"
4
5 #define INBUF_LEN 4 //数据长度
6
7 unsigned char inbuf1[INBUF_LEN],inbuf2[INBUF_LEN];
8 unsigned char checksum,count3;
9 bit read_flag= 1 ;
10
11 void init_serialcomm( void )
12 {
13 1 ///*
14 1 inbuf1[0]='A';
15 1 inbuf1[1]='B';
16 1 inbuf1[2]='C';
17 1 inbuf1[3]='D';
18 1 //*/
19 1 //inbuf1[INBUF_LEN]={'a','b','c','d'};
20 1 SCON = 0x50 ; //SCON: serail mode 1, 8-bit UART, enable ucvr 字串8
21 1 TMOD |= 0x20 ; //TMOD: timer 1, mode 2, 8-bit reload
22 1 PCON |= 0x80 ; //SMOD=1;
23 1 TH1 = 0xF4 ; //Baud:4800 fosc=11.0592MHz
24 1 IE |= 0x90 ; //Enable Serial Interrupt
25 1 TR1 = 1 ; // timer 1 run
26 1 // TI=1;
27 1 }
28
29 //向串口发送一个字符
30 void send_char_com( unsigned char ch)
31 {
32 1 SBUF=ch;
33 1 while (TI== 0 );
34 1 TI= 0 ;
35 1 }
36
37 //向串口发送一个字符串,strlen为该字符串长度
38 void send_string_com( unsigned char *str, unsigned int strlen)
39 {
40 1 unsigned int k= 0 ;
41 1 do
42 1 {
43 2 send_char_com(*(str + k));
44 2 k++;
45 2 } while (k < strlen);
46 1 }
47
48
49
50
51
52 //串口接收中断函数
53 void serial () interrupt 4 using 3
54 {
55 1 if (RI)
C51 COMPILER V8.02 EXAMPLE 08/16/2008 17:20:01 PAGE 2
56 1 {
57 2 unsigned char ch;
58 2 RI = 0 ;
59 2 ch=SBUF;
60 2 if (ch> 127 )
61 2 {
62 3 count3= 0 ;
63 3 inbuf2[count3]=ch;
64 3 checksum= ch- 128 ;
65 3 }
66 2 else
67 2 {
68 3 count3++;
69 3 inbuf2[count3]=ch;
70 3 checksum ^= ch;
71 3 if ( (count3==(INBUF_LEN- 1 )) && (!checksum) )
72 3 {
73 4 read_flag= 1 ; //如果串口接收的数据达到INBUF_LEN个,且校验没错,
74 4 //就置位取数标志
75 4 }
76 3 }
77 2 }
78 1 }
79
80
81 main()
82 {
83 1 init_LCD();
84 1 clear_LCD();
85 1 init_serialcomm(); //初始化串口
86 1 while ( 1 )
87 1 {
88 2 //if (read_flag) //如果取数标志已置位,就将读到的数从串口发出
89 2 {// 字
90 3 read_flag= 0 ; //取数标志清0
91 3 gotoxy(1,0);
92 3 display_LCD_string(inbuf2);
93 3 send_string_com(inbuf1,INBUF_LEN);
94 3
95 3 }
96 2 }
97 1
98 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 196 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 10 6
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -