哪位兄弟调试成功nRF24L01的无应答模式,最近我在用它的时候,感觉非常怪异,不能正常发射。采用的是pic单片机
/* NRF24L01初始化*/
void M1_Config24L01(void)
{
CLR_CE_NRF(); /* chip enable,待机模式I */
SET_CS_NRF(); /* Spi disable */
CLR_CLK1_NRF(); /* Spi clock line init low */
// M1_SPI_RW_Reg(WRITE_REG + CONFIG, 0x3e);
// M1_SPI_RW_Reg(WRITE_REG+SETUP_AW,0x01);
M1_SPI_Write_Buf(WRITE_REG + TX_ADDR, RF_ID_DEST, TX_ADR_WIDTH); /* 写本地地址 */
M1_SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, M1_ID_SELF, RX_ADR_WIDTH); /* 写接收端地址*/
M1_SPI_Write_Buf(WRITE_REG + RX_ADDR_P1, M1_IDCH1_SELF, RX_ADR_WIDTH);
M1_SPI_RW_Reg(WRITE_REG + EN_AA, 0x00); /* 频道0自动 ACK应答允许*/
M1_SPI_RW_Reg(WRITE_REG + SETUP_RETR, 0x00); // 禁止自动重发
M1_SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x03); /* 允许接收地址只有频道0,如果需要多频道可以参考Page21 */
M1_SPI_RW_Reg(WRITE_REG + RF_CH, 0); /* 设置信道工作为2.4GHZ,收发必须一致*/
M1_SPI_RW_Reg(WRITE_REG + RX_PW_P0, RX_PLOAD_WIDTH); /* 设置接收数据长度,本次设置为32字节*/
M1_SPI_RW_Reg(WRITE_REG + RX_PW_P1, RX_PLOAD_WIDTH); /* 设置接收数据长度,本次设置为32字节*/
M1_SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07); /* 设置发射速率为1MHZ,发射功率为最大值0dB */
}
/***********************************************************************************************************
/*函数:void nRF24L01_TxPacket(byte * tx_buf)
/*功能:发送 tx_buf中数据
/**********************************************************************************************************/
void M1_nRF24L01_TxPacket(/*byte *add_dest, */byte * tx_buf)
{
// byte status, uchar_ctr;
// M1_SPI_RW_Reg(0x27,0XFF);
// M1_SPI_Write_Buf(WRITE_REG + TX_ADDR, add_dest, TX_ADR_WIDTH); /* 装载接收端地址*/
// M1_SPI_Write_Buf(WRITE_REG + TX_ADDR, add_dest, TX_ADR_WIDTH); /* 装载接收端地址*/
CLR_CE_NRF(); /* StandBy I模式*/
// M1_SPI_Write_Buf(WRITE_REG + TX_ADDR, RF_ID_DEST, TX_ADR_WIDTH);
// M1_SPI_Write_Buf(WRITE_REG + TX_ADDR, add_dest, TX_ADR_WIDTH); /* 装载接收端地址*/
// M1_SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, add_dest, TX_ADR_WIDTH); /* 装载接收端地址*/
// M1_SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, RF_ID_DEST, TX_ADR_WIDTH); /* 装载接收端地址*/
M1_SPI_Write_Buf(WRITE_REG + TX_ADDR, add_dest, TX_ADR_WIDTH); /* 装载接收端地址*/
M1_SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); /* 装载数据 */
M1_SPI_RW_Reg(WRITE_REG + CONFIG, 0x2e); /* IRQ收发完成中断响应,16位CRC,主发送*/
SET_CE_NRF(); /* 置高CE,激发数据发送*/
Delay130();
//CLR_CE_NRF();
}
谢谢!