高级会员
- 积分
- 602
- 金钱
- 602
- 注册时间
- 2013-10-18
- 在线时间
- 59 小时
|
<div>void NRF24L01_TX_Mode(void)</div>
<div>{<span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_CE=0;<span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Buf(WRITE_REG_NRF+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);//写TX节点地址 </div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH); //设置TX节点地址,主要为了使能ACK<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_Write_Reg(WRITE_REG_NRF+EN_AA,0x01); //使能通道0的自动应答 </div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Reg(WRITE_REG_NRF+EN_RXADDR,0x01); //使能通道0的接收地址 </div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Reg(WRITE_REG_NRF+SETUP_RETR,0x1a);//设置自动重发间隔时间:500us + 86us;最大自动重发次数:10次</div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Reg(WRITE_REG_NRF+RF_CH,40); //设置RF通道为40</div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span><span style="color:#e53333;">NRF24L01_Write_Reg(WRITE_REG_NRF+RF_SETUP,0x27); //</span><span style="color:#e53333;"> </span><span style="color:#e53333;">0x27</span><span style="color:#e53333;"> </span><span style="color:#e53333;">:设置TX发射参数,0db增益,250kbps,低噪声增益开启 (0x0f: 设置TX发射参数,0db增益,2Mbps,低噪声增益开启)</span></div>
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_Write_Reg(WRITE_REG_NRF+CONFIG,0x0e); //配置基本工作模式的参数WR_UP,EN_CRC,16BIT_CRC,接收模式,开启所有中断</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF24L01_CE=1;//CE为高,10us后启动发送</div>
<div>}<br />
实测降低通讯速率可以增加通讯的稳定性。对速度不高但距离相对较高的场合这样做可以间接增加通讯距离。<br />
其他详细的设置可以查看<span style="color:#e53333;">英文数据手册,反正中文的我没找到这个寄存器的设置。</span><br />
<br />
<span class="Apple-tab-span" style="white-space:pre;"> </span></div> |
|