light.lst
来自「基于89c2051开发的ptr8000一对多无线通信程序.」· LST 代码 · 共 182 行
LST
182 行
C51 COMPILER V6.23a LIGHT 04/27/2006 17:18:21 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE LIGHT
OBJECT MODULE PLACED IN Light.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Light.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <reg51.h>
2 #include <stdio.h>
3 bit startframe=0,com2rb=1;
4 unsigned char TLV=0x80; //7200 times per second for 11059200. 0.14 ms per time.
5 unsigned char THV=0xff; //0xfe; if 8times baudrate it's 0x60 and 0xff respectively.
6 unsigned char com2sbufp=0,com2buffs[2],com2buffr[20],com2buffrp=0;
7 unsigned short SECTICKS=7200; //4800; //65536/(65536-(THV*256+TLV))*18;
8 unsigned short HALFSECTICKS=3600;
9 unsigned char rbuff[20],sbuff[11];
10 unsigned char rbuffp=0;
11 unsigned char triggle=0,chno=0,ensend=0,rest;
12 unsigned char ticks1=0,ticks2=0,ticksl2=0,ticksh2=0,ticks3;
13 unsigned char temptl0,tempth0;
14 unsigned short filterB=0xffff,count=0,com2sbuf;
15 unsigned char e1count=0,irbytep=0;
16 unsigned short irbyte=0;
17 sbit P32 = P3^2;
18 sbit COM2R=P3^0;
19 sbit COM2S=P3^1;
20 void delay()
21 {
22 1 unsigned short i,j;
23 1 for(i=0;i<30;i++) j=i;
24 1 }
25 void e0int() interrupt 0
26 {
27 1 P1=P1 ^ 0x80; // Feed watchdog.
28 1 ticks3++;
29 1 }
30 void e1int() interrupt 2
31 {
32 1 //ticks1++;
33 1 /*irbyte&=0xfeff;
34 1 if(e1count>=12) irbyte|=0x0100;
35 1 irbyte>>=1;
36 1 if(++irbytep==8)
37 1 {
38 1 SBUF=(unsigned char)irbyte;
39 1 //putchar(irbyte);
40 1 irbytep=0;
41 1 }*/
42 1 if(e1count!=0)
43 1 {
44 2 SBUF=e1count;
45 2 e1count=0;
46 2 }
47 1 }
48 void t0int() interrupt 1
49 {
50 1 // unsigned char i;
51 1 temptl0=TL0;
52 1 //tempth0=TH0;
53 1 TL0=TLV+temptl0+3; //current instruction use 6 t-cycls.
54 1 TH0=THV; //+tempth0;
55 1 e1count++;
C51 COMPILER V6.23a LIGHT 04/27/2006 17:18:21 PAGE 2
56 1 filterB<<=1;
57 1 filterB&=0xfffe;
58 1 filterB|=COM2R;
59 1 switch(filterB) //switch (filterB&0x7) //now 24 times sample serial signal.
60 1 {
61 2 case 0xffff:
62 2 com2rb=1;
63 2 break;
64 2 case 0x0:
65 2 com2rb=0;
66 2 if(!startframe)
67 2 {
68 3 startframe=1;
69 3 com2sbufp=0;
70 3 rest=(count&0x18)+4;
71 3 }
72 2 break;
73 2 default:
74 2 break;
75 2 }
76 1 if(startframe && ((count&0x18) == rest))
77 1 {
78 2 com2sbuf>>=1;
79 2 com2sbuf&=0xfeff;
80 2 if(com2rb) com2sbuf|=0x0100;
81 2 com2sbufp++;
82 2 if(com2sbufp==10)
83 2 {
84 3 startframe=0;
85 3 if(com2sbuf&0x100)
86 3 {
87 4 com2buffr[com2buffrp]=com2sbuf;
88 4 //TI=0;
89 4 //SBUF=com2sbuf;
90 4 if(++com2buffrp==20) com2buffrp=0;
91 4 }
92 3 }
93 2 }
94 1 count++;
95 1 if(count == SECTICKS)
96 1 {
97 2 count=0;
98 2 triggle=1;
99 2 }
100 1 }
101 void comint() interrupt 4
102 {
103 1 if(RI)
104 1 {
105 2 RI=0;
106 2 rbuff[rbuffp]=SBUF;
107 2 if((rbuff[rbuffp] == 'E') && (rbuff[(rbuffp+11)%20] == 'S') && (rbuff[(rbuffp+12)%20] == '0'))
108 2 {
109 3 switch (rbuff[(rbuffp+13)%20])
110 3 {
111 4 case 'A': ensend=1;
112 4 break;
113 4 case 'D':
114 4 break;
115 4 default:break;
116 4 }
117 3 }
C51 COMPILER V6.23a LIGHT 04/27/2006 17:18:21 PAGE 3
118 2 rbuffp++;
119 2 if(rbuffp == 20) rbuffp=0;
120 2 }
121 1 }
122 void main (void)
123 {
124 1 unsigned char i;
125 1 sbuff[0]=0xff;
126 1 sbuff[1]='S';
127 1 sbuff[2]='0';
128 1 sbuff[9]=0;
129 1 sbuff[10]='E';
130 1 SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
131 1 TMOD |= 0x21; /* TMOD: timer 1, mode 2, 8-bit reload */
132 1 //TH1 = 0xa0; //0xd8; /* TH1: 300 bps for 11059200 ,reload value for 1200 baud @ 184320000MHz
-*/
133 1 TH1 = 0xfd; //9600 bps. for 11.05
134 1 TR1 = 1; /* TR1: timer 1 run */
135 1 IT1 = 1;
136 1 IT0 = 1;
137 1 TI = 1; /* TI: set TI to send first char of UART */
138 1 TR0 = 1;
139 1 IE = 0x87; //en e0,t0
140 1 while (1)
141 1 {
142 2 if (triggle==1)
143 2 {
144 3 //P32=0;
145 3 //for(i=0;i<11;i++) putchar(sbuff[i]);
146 3 //putchar(temptl0);
147 3 triggle=0;
148 3 //P32=1;
149 3 }
150 2 delay();
151 2 }
152 1 }
*** WARNING C280 IN LINE 124 OF LIGHT.C: 'i': unreferenced local variable
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 392 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 83 3
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?