初级会员
- 积分
- 58
- 金钱
- 58
- 注册时间
- 2015-4-16
- 在线时间
- 2 小时
|
发表于 2015-9-29 17:40:44
|
显示全部楼层
回复【6楼】正点原子:
<br>---------------------------------
<br>如何设置其他通道的收发,我使用0通道可以接收数据,但是用其他通道就接收不到数据,而且发送端也一直显示状态是发送数据。
<br>发射端
<br>const u8 TX_ADDRESS[TX_ADR_WIDTH]={0x34,0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS0[RX_ADR_WIDTH]={0x34,0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS1[RX_ADR_WIDTH]={'1',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS2[RX_ADR_WIDTH]={'2',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS3[RX_ADR_WIDTH]={'3',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS4[RX_ADR_WIDTH]={'4',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS5[RX_ADR_WIDTH]={'5',0x43,0x10,0x10,0x01};
<br>void NRF24L01_TX_Mode(void)
<br>{
<br> NRF24L01_CE=0;
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P0,(u8*)RX_ADDRESS0,RX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P1,(u8*)RX_ADDRESS1,RX_ADR_WIDTH);//这一步有没有必要,是不是直接使能通道
<br> 的接收地址就可以了
<br>
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+EN_AA,0x02); //使能通道1的应答模式;如果将0x02设置为0x03 ,使能通道0、1的应答模式
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+EN_RXADDR,0x02);// 使能通道1的接收地址;如果将0x02设置为0x03 ,使能通道0、1的接收地址。
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+SETUP_RETR,0x1a);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RF_CH,50);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RF_SETUP,0x0f);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+CONFIG,0x0e);
<br> NRF24L01_CE=1;
<br>}
<br>
<br>
<br>接收端
<br>const u8 TX_ADDRESS[TX_ADR_WIDTH]={0x34,0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS0[RX_ADR_WIDTH]={0x34,0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS1[RX_ADR_WIDTH]={'1',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS2[RX_ADR_WIDTH]={'2',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS3[RX_ADR_WIDTH]={'3',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS4[RX_ADR_WIDTH]={'4',0x43,0x10,0x10,0x01};
<br>const u8 RX_ADDRESS5[RX_ADR_WIDTH]={'5',0x43,0x10,0x10,0x01};
<br>void NRF24L01_RX_Mode(void)
<br>{
<br> NRF24L01_CE=0;
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P0,(u8*)RX_ADDRESS0,RX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P1,(u8*)RX_ADDRESS1,RX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P2,(u8*)RX_ADDRESS2,RX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P3,(u8*)RX_ADDRESS3,RX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P4,(u8*)RX_ADDRESS4,RX_ADR_WIDTH);
<br> NRF24L01_Write_Buf(WRITE_REG_NRF+RX_ADDR_P5,(u8*)RX_ADDRESS5,RX_ADR_WIDTH);
<br>
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+EN_AA,0x3f);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+EN_RXADDR,0x3f);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RF_CH,50);
<br>
<br>
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RX_PW_P0,RX_PLOAD_WIDTH);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RX_PW_P1,RX_PLOAD_WIDTH);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RX_PW_P2,RX_PLOAD_WIDTH);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RX_PW_P3,RX_PLOAD_WIDTH);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RX_PW_P4,RX_PLOAD_WIDTH);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RX_PW_P5,RX_PLOAD_WIDTH);
<br>
<br>
<br>
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+RF_SETUP,0x0f);
<br> NRF24L01_Write_Reg(WRITE_REG_NRF+CONFIG, 0x0f);
<br> NRF24L01_CE = 1;
<br>}
<br>
<br>有许多问题
<br>1.为什么在发送函数中使用通道0(0x01),接收端就可以接收数据,而使用通道1(0x02)却不可以?
<br>2.当将使能通道的应答模式和使能通道的接收地址中的0x02设置0x03,接收端又可以接收数据,其实应该还是通道0接收的数据
<br>3.当接收端接收不到数据时,为什么发送端接收到应答,显示发送数据而不是发送失败, |
|