新手入门
- 积分
- 27
- 金钱
- 27
- 注册时间
- 2013-8-29
- 在线时间
- 0 小时
|
如题,由430发送数据,stm32接收。有一定的概率接收成功,但是概率极低。这是怎么回事?大概什么问题?<br />
附上接收包函数。<br />
<div>u8 NRF24L01_RxPacket(u8 *rxbuf)</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>u8 sta;<span class="Apple-tab-span" style="white-space:pre;"> </span> <span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>SPI2_SetSpeed(SPI_SPEED_8); //spi速度为9Mhz(24L01的最大SPI时钟为10Mhz) </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>sta=NRF24L01_Read_Reg(STATUS); //读取状态寄存器的值 <span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Reg(WRITE_REG+STATUS,sta); //清除TX_DS或MAX_RT中断标志</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>if(sta&RX_OK)//接收到数据</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Read_Buf(RD_RX_PLOAD,rxbuf,RX_PLOAD_WIDTH);//读取数据</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_CSN = 0;</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Reg(FLUSH_RX,0xff);//清除RX FIFO寄存器 </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_CSN = 1;</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>return 0; </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>}<span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>return 1;//没收到任何数据</div>
<div>}</div>
<br /> |
|