315M无线收发系统编码,解码程序
源代码在线查看: receive.lst
C51 COMPILER V9.01 RECEIVE 07/20/2013 17:14:00 PAGE 1
C51 COMPILER V9.01, COMPILATION OF MODULE RECEIVE
OBJECT MODULE PLACED IN receive.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE receive.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include
2 #define uint unsigned int
3 #define uchar unsigned char
4
5 bit begin;//开始解码标志位
6 uint time;
7 uchar num=0;//数脉冲个数
8 unsigned char addrh,addrl;//接收地址
9 unsigned char key;//接收数据
10
11 void init()
12 {
13 1 INT0=1;
14 1
15 1 TMOD=0x01;
16 1 TH0=0;
17 1 TL0=0;
18 1 EA=1; //开总中断
19 1 EX0=1; //开外部中断
20 1 IT0=1; //跳变沿触发中断
21 1 }
22
23 void main()
24 {
25 1 init();
26 1 begin=0;
27 1 P2=0x00;
28 1 P1=0x00;
29 1
30 1 while(1)
31 1 {
32 2 //P2=addrh;
33 2 P1=addrl;
34 2 P2=key;
35 2 }
36 1
37 1 }
38
39 void accept_tongbu() interrupt 0
40 {
41 1 static unsigned char tempaddrl,tempaddrh;//接收地址缓存
42 1 static unsigned char tempkey;//接收数据缓存 EX0=0;
43 1 TR0=1;
44 1 while(!INT0); //等待低电平结束
45 1 TR0=0;
46 1 time=(TH0 47 1 if((time>14000)&&(time 48 1 {
49 2 TH0=0;TL0=0;
50 2 EX0=1;//关闭外部中断
51 2 }
52 1 else
53 1 {
54 2 TH0=0;TL0=0;
55 2 EX0=1;
C51 COMPILER V9.01 RECEIVE 07/20/2013 17:14:00 PAGE 2
56 2 begin=1;
57 2 }
58 1
59 1 if(begin)//开始解码了
60 1 {
61 2 if(num 62 2 {
63 3 tempaddrl=tempaddrl>>1;//将接收的到最低位移到最高位
64 3 if(time 65 3 {
66 4 tempaddrl|=0x80;//宽脉冲为1
67 4 }
68 3 num++;//中断次数加1
69 3 }
70 2 else if(num 71 2 {
72 3 tempaddrh=tempaddrh>>1;//将接收的到最低位移到最高位
73 3 if(time 74 3 {
75 4 tempaddrh|=0x80;//宽脉冲为1
76 4 }
77 3 num++;//中断次数加1
78 3 }
79 2 else if(num 80 2 {
81 3 tempkey=tempkey>>1;
82 3 if(time 83 3 {
84 4 tempkey|=0x80;
85 4 }
86 3 num++;
87 3 }
88 2 else//cntint大于24也就是中断了25次时,关闭外部中断0,等待同步码
89 2 {
90 3 TH0=0;
91 3 TL0=0;
92 3 EX0=1;
93 3 time=0;
94 3 num=0;
95 3 begin=0;
96 3
97 3 addrh=tempaddrh;
98 3 addrl=tempaddrl;
99 3 key=tempkey;
100 3
101 3 tempaddrh=0;
102 3 tempaddrl=0;
103 3 tempkey=0;
104 3 }
105 2 }
106 1
107 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 263 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 9 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
C51 COMPILER V9.01 RECEIVE 07/20/2013 17:14:00 PAGE 3
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)