完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我有个问题想请教下大家。在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; } |
|
相关推荐
2个回答
|
|
改为
const u8 RX_ADDRESS_P0[RX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x00}; const u8 RX_ADDRESS_P1[RX_ADR_WIDTH]={0x01,0x10,0x10,0x03,0x00}; const u8 RX_ADDRESS_P2[RX_ADR_WIDTH]={0x02,0x10,0x10,0x03,0x00}; const u8 RX_ADDRESS_P3[RX_ADR_WIDTH]={0x03,0x10,0x10,0x03,0x00}; const u8 RX_ADDRESS_P4[RX_ADR_WIDTH]={0x04,0x10,0x10,0x03,0x00}; const u8 RX_ADDRESS_P5[RX_ADR_WIDTH]={0x05,0x10,0x10,0x03,0x00}; |
|
|
|
您好,我刚才试了试,把你的这个复制到代码中,并把const u8 TX_ADDRESS[TX_ADR_WIDTH]={0x43,0x10,0x10,0x03,0x02}; 改为和const u8 RX_ADDRESS_P2[RX_ADR_WIDTH]={0x02,0x10,0x10,0x03,0x00};一样,想用通道2来接收,还是发送失败,
|
|
|
|
只有小组成员才能发言,加入小组>>
如何使用STM32+nrf24l01架构把有线USB设备无线化?
2543 浏览 7 评论
请问能利用51单片机和nRF24L01模块实现实时语音无线传输吗?
2328 浏览 5 评论
3148 浏览 3 评论
2799 浏览 8 评论
为什么ucosii上移植lwip后系统进入了HardFault_Handler?
2759 浏览 4 评论
请教各位大咖:有没有接收频率32M左右的芯片推荐的?先感谢啦!
603浏览 1评论
852浏览 0评论
962浏览 0评论
618浏览 0评论
444浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-20 04:44 , Processed in 1.342177 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号