初级会员
- 积分
- 112
- 金钱
- 112
- 注册时间
- 2014-12-24
- 在线时间
- 8 小时
|
大家好,我有个问题想请教下大家。在NRF24L01无线通信这个实验中,原来的代码是用通道0做数据的接收和发送,我把原子哥的代码稍作修改了下,想改用通道2做数据的接收和发送,下面是我做修改的通道程序,和原来的程序对比的图片,同样的方法修改为通道一就没问题,改为通道2就是调不通,大家帮我看下具体问题在哪儿,thank you!这是原子哥原来的代码,
const u8 TX_ADDRESS[TX_ADR_WIDTH]={0x34,0x43,0x10,0x10,0x01};
const u8 RX_ADDRESS[RX_ADR_WIDTH]={0x34,0x43,0x10,0x10,0x01};
void NRF24L01_RX_Mode(void)
{
NRF24L01_CE=0;
NRF24L01_Write_Buf(NRF_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_AA,0x01);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_RXADDR,0x01);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_CH,40);
NRF24L01_Write_Reg(NRF_WRITE_REG+RX_PW_P0,RX_PLOAD_WIDTH);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_SETUP,0x0f);
NRF24L01_Write_Reg(NRF_WRITE_REG+CONFIG, 0x0f);
NRF24L01_CE = 1;
}
void NRF24L01_TX_Mode(void)
{
NRF24L01_CE=0;
NRF24L01_Write_Buf(NRF_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);
NRF24L01_Write_Buf(NRF_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_AA,0x01);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_RXADDR,0x01);
NRF24L01_Write_Reg(NRF_WRITE_REG+SETUP_RETR,0x1a);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_CH,40);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_SETUP,0x0f);
NRF24L01_Write_Reg(NRF_WRITE_REG+CONFIG,0x0e);
NRF24L01_CE=1;
}
下面是我修改后的代码,麻烦大家帮我看下那个地方出问题了,纠结了好长时间:
const u8 TX_ADDRESS[TX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x02};
const u8 RX_ADDRESS_P0[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x00};
const u8 RX_ADDRESS_P1[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x01};
const u8 RX_ADDRESS_P2[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x02};
const u8 RX_ADDRESS_P3[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x03};
const u8 RX_ADDRESS_P4[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x04};
const u8 RX_ADDRESS_P5[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x05};
void NRF24L01_TX_Mode(void)
{
NRF24L01_CE=0;
NRF24L01_Write_Buf(NRF_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);
NRF24L01_Write_Buf(NRF_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS_P2,RX_ADR_WIDTH);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_AA,0x01);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_RXADDR,0x01);
NRF24L01_Write_Reg(NRF_WRITE_REG+SETUP_RETR,0x1a);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_CH,40);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_SETUP,0x0f);
NRF24L01_Write_Reg(NRF_WRITE_REG+CONFIG,0x0e);
NRF24L01_CE=1;
}
void NRF24L01_RX_Mode(void)
{
NRF24L01_CE=0;
NRF24L01_Write_Buf(NRF_WRITE_REG+RX_ADDR_P2,(u8*)RX_ADDRESS_P2,RX_ADR_WIDTH);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_AA,0x04);
NRF24L01_Write_Reg(NRF_WRITE_REG+EN_RXADDR,0x04);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_CH,40);
NRF24L01_Write_Reg(NRF_WRITE_REG+RX_PW_P2,RX_PLOAD_WIDTH);
NRF24L01_Write_Reg(NRF_WRITE_REG+RF_SETUP,0x0f);
NRF24L01_Write_Reg(NRF_WRITE_REG+CONFIG, 0x0f);
NRF24L01_CE = 1;
}
|
|