|
经过1周的努力,现在可以发了,但是却怎么都收不到数据,请教下,软件没有初始化好还是硬件问题呢?
初始化函数- SDN_CLR;
- Delay_ms(1000);
- SpiWriteAddressData( 0x07 , 0x80);
- Delay_ms(100);
- SpiReadAddressData(0x03);
- SpiReadAddressData(0x04);
-
- SpiWriteAddressData( 0x05 , 0x00);
- SpiWriteAddressData( 0x06 , 0x00);
-
- SpiWriteRegister(0x09, 0x7F);
-
- SpiWriteAddressData( 0x0B , 0x12);
- SpiWriteAddressData( 0x0C , 0x15);
- SpiWriteAddressData( 0x0D , 0x1F);
-
- SpiWriteAddressData( 0x75 , 0x53);
- SpiWriteAddressData( 0x76 , 0x4b);
- SpiWriteAddressData( 0x77 , 0x00);
-
- SpiWriteRegister(0x6E, 0x4E); //write 0x4E to the TXDataRate 1 register
- SpiWriteRegister(0x6F, 0xA5); //write 0xA5 to the TXDataRate 0 register
- SpiWriteRegister(0x70, 0x2C);
- SpiWriteRegister(0x72, 0x48);
- SpiWriteRegister(0x1C, 0x1E); //write 0x1E to the IF Filter Bandwidth register
- SpiWriteRegister(0x20, 0xD0); //write 0xD0 to the Clock Recovery Oversampling Ratio register
- SpiWriteRegister(0x21, 0x00); //write 0x00 to the Clock Recovery Offset 2 register
- SpiWriteRegister(0x22, 0x9D); //write 0x9D to the Clock Recovery Offset 1 register
- SpiWriteRegister(0x23, 0x49); //write 0x49 to the Clock Recovery Offset 0 register
- SpiWriteRegister(0x24, 0x00); //write 0x00 to the Clock Recovery Timing Loop Gain 1 register
- SpiWriteRegister(0x25, 0x24); //write 0x24 to the Clock Recovery Timing Loop Gain 0 register
- SpiWriteRegister(0x1D, 0x40); //write 0x40 to the AFC Loop Gearshift Override register
- SpiWriteRegister(0x1E, 0x0A); //write 0x0A to the AFC Timing Control register
- SpiWriteRegister(0x2A, 0x20);
- SpiWriteRegister(0x34, 0x0A); //write 0x0A to the Preamble Length register
- //set preamble detection threshold to 20bits
- SpiWriteRegister(0x35, 0x2A); //write 0x2A to the Preamble Detection Control register
- //Disable header bytes; set variable packet length (the length of the payload is defined by the
- //received packet length field of the packet); set the synch word to two bytes long
- SpiWriteRegister(0x33, 0x02); //write 0x02 to the Header Control2 register
- //Set the sync word pattern to 0x2DD4
- SpiWriteRegister(0x36, 0x2D); //write 0x2D to the Sync Word 3 register
- SpiWriteRegister(0x37, 0xD4); //write 0xD4 to the Sync Word 2 register
- //enable the TX & RX packet handler and CRC-16 (IBM) check
- SpiWriteRegister(0x30, 0x8D); //write 0x8D to the Data Access Control register
- //Disable the receive header filters
- SpiWriteRegister(0x32, 0x00 ); //write 0x00 to the Header Control1 register
- //enable FIFO mode and GFSK modulation
- SpiWriteRegister(0x71, 0x63); //write 0x63 to the Modulation Mode Control 2 register
- /*set the GPIO's according to the RF switch */
- SpiWriteRegister(0x0C, 0x12); //write 0x12 to the GPIO1 Configuration(set the TX state)
- SpiWriteRegister(0x0D, 0x15); //write 0x15 to the GPIO2 Configuration(set the RX state)
- /*set the non-default Si443x registers*/
- //set cap. bank
- SpiWriteRegister(0x09, 0x1f); //write 0xD7 to the Crystal Oscillator Load Capacitance register
- /*enable receiver chain*/
- SpiWriteRegister(0x07, 0x05); //write 0x05 to the Operating Function Control 1 register
- //Enable two interrupts:
- // a) one which shows that a valid packet received: 'ipkval'
- // b) second shows if the packet received with incorrect CRC: 'icrcerror'
- SpiWriteRegister(0x6D, 0x1F);
- SpiWriteRegister(0x05, 0x03); //write 0x03 to the Interrupt Enable 1 register
- SpiWriteRegister(0x06, 0x00); //write 0x00 to the Interrupt Enable 2 register
-
- SpiWriteRegister(0x07, 0x01);
复制代码 图纸:
用的是B版的4432,也用excel表格计算过,也是不行的。
接受发送函数用的苹果猫给的参考程序。- void RF_R(unsigned char *d)
- {
- unsigned char index,yyy,ttt;
- SpiWriteAddressData( OperatingFunctionControl2 , 0x02);
- SpiWriteAddressData( OperatingFunctionControl2 , 0x00);
- SpiWriteAddressData( OperatingFunctionControl1 , 0x05);
- while(1)
- {
- yyy = SpiReadAddressData(InterruptStatus2);
- yyy = SpiReadAddressData(InterruptStatus1);
- LEDRX_ON;
- WDR();
- if(yyy&0x02) break;
- }
- LEDRX_OFF;
- SpiWriteAddressData( OperatingFunctionControl1 , 0x01);
- ttt = SpiReadAddressData(ReceivedPacketLength);
- for(index=0;index<ttt;index++)
- {
- d[index]=SpiReadAddressData(FIFOAccess);
- }
- SendUARTData(d,ttt);
- }
- void RF_T(unsigned char *d,unsigned char l)
- {
- unsigned char i;
- SpiWriteAddressData( OperatingFunctionControl1 , 0x01);
- SpiWriteAddressData( OperatingFunctionControl2 , 0x01);
- SpiWriteAddressData( OperatingFunctionControl2 , 0x00);
- SpiWriteAddressData( InterruptEnable1 , 0x00);
- SpiWriteAddressData( InterruptEnable2 , 0x00);
- SpiWriteAddressData( TransmitPacketLength , l);
- for(i=0;i<l;i++)
- {
- SpiWriteAddressData( FIFOAccess , *d);
- d++;
- }
- SpiWriteAddressData( OperatingFunctionControl1 , 0x09);
- SpiWriteAddressData( InterruptEnable1 , 0x04);//使能发送有效包中断
- while((SpiReadAddressData(InterruptStatus1)&0x04)==0)
- {
- LEDTX_ON;
- WDR();
- }
- LEDTX_OFF;
- }
复制代码 只要能完成最起码的接收发送就行,没做过无线,调试起来真是一头雾水,求高手帮帮忙。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|