初级会员
- 积分
- 101
- 金钱
- 101
- 注册时间
- 2011-4-20
- 在线时间
- 0 小时
|
<h3> 好久没发帖。。忙于期末考试和校电子设计比赛。这几天重操旧业。。拾起STM32~~~调了三天的无线NRF24L01模块。。通道0和通道1都能自由自在的通信了。。可是通道2以上调了2天一点进展也没有。。搜了网上各种资料。目前还没有发现有调通通道2的。很多所谓的已调通所有通道。都是骗人的啊@_@!程序里就只有通道0和1调通,能实现2发1收,然后来了一句,6发1收同理。。同理!!我怎么就没有发现同理呢。。怎么都出不来啊!!不抱怨了。。上程序代码:</h3>
<h3>//发送地址<br />
const uint8_t TX0_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA1}; //发送地址<br />
const uint8_t TX1_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA2}; //发送地址<br />
const uint8_t TX2_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA3}; //发送地址<br />
const uint8_t TX3_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA4}; //发送地址<br />
const uint8_t TX4_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA5}; //发送地址<br />
const uint8_t TX5_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA6}; //发送地址<br />
//接收地址<br />
const uint8_t RX0_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA1}; //接收地址<br />
const uint8_t RX1_ADDRESS[RX_ADDR_WIDTH]={0x62,0x62,0x62,0x62,0xA2}; //接收地址<br />
const uint8_t RX2_ADDRESS[1]={0xA3}; //接收地址,高32位等于RX1_ADDRESS<br />
const uint8_t RX3_ADDRESS[1]={0xA4}; //接收地址<br />
const uint8_t RX4_ADDRESS[1]={0xA5}; //接收地址<br />
const uint8_t RX5_ADDRESS[1]={0xA6}; //接收地址</h3>
<h3>//发射配置</h3>
<h3>void TX_Mode(uint8_t *TX_ADDRESS)<br />
{ <br />
NRF24L01_CE=0; <br />
NRF24L01_Write_Buf(MY_WRITE_REG+TX_ADDR,(uint8_t*)TX_ADDRESS,TX_ADDR_WIDTH); //写TX节点地址 <br />
NRF24L01_Write_Buf(MY_WRITE_REG+RX_ADDR_P0,(uint8_t*)TX_ADDRESS,RX_ADDR_WIDTH); //设置RX节点地址<br />
//主要为了使能ACK <br />
NRF24L01_Write_Reg(MY_WRITE_REG+EN_AA,0x01); //使能通道0的自动应答 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+EN_RXADDR,0x01); //使能通道0的接收地址 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+SETUP_RETR,0x1a); //设置自动重发间隔时间:500us + 86us<br />
//最大自动重发次数:10次<br />
NRF24L01_Write_Reg(MY_WRITE_REG+RF_CH,40); //设置RF通道为40<br />
NRF24L01_Write_Reg(MY_WRITE_REG+RF_SETUP,0x0f); //设置TX发射参数,0db增益,2Mbps,低噪声增益开启 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+CONFIG,0x0e); //配置基本工作模式的参数<br />
/ /PWR_UP,EN_CRC,16BIT_CRC,发射模式<br />
NRF24L01_CE=1; //CE为高,10us后启动发送<br />
}<br />
//接收配置</h3>
<h3>void RX2_Mode(void)<br />
{<br />
NRF24L01_CE=0; <br />
NRF24L01_Write_Buf(MY_WRITE_REG+RX_ADDR_P2,(uint8_t*)RX2_ADDRESS,1); //选择通道2作为接收<br />
//写RX节点地址RX_ADDRESS<br />
NRF24L01_Write_Reg(MY_WRITE_REG+EN_AA,0x04); //使能通道2的自动应答 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+EN_RXADDR,0x04); //使能通道2的接收地址 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+RF_CH,40); //设置RF通信频率 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+RF_CH,40); //设置RF通信频率 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+RX_PW_P2,RX_DATA_WIDTH);//选择通道2的有效数据宽度 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+RF_SETUP,0x0f); //设置TX发射参数,0db增益,2Mbps,低噪声增益开启 <br />
NRF24L01_Write_Reg(MY_WRITE_REG+CONFIG, 0x0f); //配置基本工作模式的参数<br />
//PWR_UP,EN_CRC,16BIT_CRC,接收模式 <br />
NRF24L01_CE = 1; //CE为高进入接收模式,130us后检测空中信息 <br />
}<br />
PS:数据手册都快被我翻烂了。。真的找不出问题所在。只能发帖求问了~~原子哥。。各位大虾~~~<img border="0" alt="" src="/static/image/smiley/kindeditor/5.gif" /></h3>
<p> </p>
<p> </p> |
|