📄 receiver.lst
字号:
C51 COMPILER V7.50 RECEIVER 11/20/2006 22:09:22 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE RECEIVER
OBJECT MODULE PLACED IN Receiver.OBJ
COMPILER INVOKED BY: D:\keil\C51\BIN\C51.EXE Receiver.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*=====================================================================
2 *
3 *由 Keil C51 V7.50 编译通过
4 *==============================================================================
5 */
6 #include <reg24e1.h>
7
8 struct RFConfig
9 {
10 unsigned char n;
11 unsigned char buf[15];
12 };
13
14 typedef struct RFConfig RFConfig;
15
16 #define ADDR_INDEX 8 // Index to address bytes in RFConfig.buf
17 #define ADDR_COUNT 4 // Number of address bytes
18
19
20 const RFConfig rconf =
21 {
22 15, //If the nRF2401 subsystem is to be configured for 2 channel RX in ShockBurst, a
23 //total of 120 bits must be shifted in during the first configuration
24 // after VDD is applied. 是不是不要120--143bit(Reserved for testing) 了
25 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 数据包是8位8位的传,地址是32位,需要CRC,是16位,
26 0xaa, 0xbb, 0x12, 0x34, 0x83, 0x6f, 0x05 //1 Mbps的 RF Data Rate,16MHz的时钟频率,调制于2404MHz.
27 }; // The MSB bit should be loaded first into the configuration register
28
29 void Delay100us(volatile unsigned char n)
30 {
31 1 unsigned char i;
32 1 while(n--)
33 1 for(i=0;i<35;i++)
34 1 ;
35 1 }
36
37
38 unsigned char SpiReadWrite(unsigned char b)
39 // Output data is shifted on negedge SCK, and input data is read on posedge SCK
40 {
41 1 EXIF &= ~0x20; // Clear SPI interrupt
42 1 SPI_DATA = b; // Move byte to send to SPI data register
43 1 while((EXIF & 0x20) == 0x00) // Wait until SPI hs finished transmitting
44 1 ;
45 1 return SPI_DATA;
46 1 }
47
48 unsigned char ReceivePacket()
49 {
50 1 unsigned char b;
51 1 CE = 1;
52 1 while(DR1 == 0)
53 1 ;
54 1 b = SpiReadWrite(0); // Firsrt write dummy byte to SPI data register,when SPI data reg
-ister have
C51 COMPILER V7.50 RECEIVER 11/20/2006 22:09:22 PAGE 2
55 1 // received data,evaluate to b
56 1 CE = 0;
57 1 return b;
58 1 }
59
60 void PutChar(char c)
61 {
62 1 while(!TI)
63 1 ;
64 1 TI = 0;
65 1 SBUF = c;
66 1 }
67
68 void Receiver(void)
69 {
70 1 unsigned char b;
71 1 CS = 1;
72 1 Delay100us(0);
73 1 for(b=0;b<rconf.n;b++)
74 1 {
75 2 SpiReadWrite(rconf.buf[b]);
76 2 }
77 1 CS = 0;
78 1
79 1 for(;;)
80 1 {
81 2 b = ReceivePacket();
82 2 PutChar(b);
83 2
84 2 }
85 1 }
86
87 void Init(void)
88 {
89 1
90 1 // Port ini
91 1 P0_ALT = 0x06; // Select alternate functions on pins P0.1 and P0.2, TXD RXD
92 1
93 1 PWR_UP = 1; // Turn on Radio
94 1 Delay100us(30); // Wait > 3ms
95 1 SPICLK = 0; // Max SPI clock (XTAL/8)
96 1 SPI_CTRL = 0x02; // Connect internal SPI controller to Radio CH1
97 1
98 1 // serial communication ini
99 1 TH1 = 243; // 19200@16MHz (when T1M=1 and SMOD=1) 19200=(2/32)*{(16M/4)*[1/(256-243)]}
-
100 1 CKCON |= 0x10; // T1M=1 (/4 timer clock)
101 1 PCON = 0x80; // SMOD=1 (double baud rate)
102 1 SCON = 0x52; // Serial mode1, enable receiver
103 1 TMOD = 0x20; // Timer1 8bit auto reload
104 1 TCON = 0x40; // Start timer1
105 1 }
106
107 void main(void)
108 {
109 1 Init();
110 1 while(1)
111 1 {
112 2 Receiver();
113 2 }
114 1 }
C51 COMPILER V7.50 RECEIVER 11/20/2006 22:09:22 PAGE 3
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 135 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 16 1
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -