微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > 大家帮帮忙,看看我的NRF24L01发送调试程序有什么问题

大家帮帮忙,看看我的NRF24L01发送调试程序有什么问题

时间:10-02 整理:3721RD 点击:
用频谱仪观察不到一点信号。
如果你有发送调试程序发我一份,感激不尽
#include "reg52.H"
#define uchar unsigned char
sbit MISO=P1^0;
sbit MOSI=P1^2;
sbit SCK=P1^7;
sbit CSN=P1^4;
sbit CE=P1^6;
uchar a[8]={
0x11,
0x33,
0x55,
0x77,
0xdd,
0xaa,
0xbb,
0xcc
};
uchar *pa=a;
uchar b[4]={0x01,0x01,0x01,0x01} ;
uchar *pb=b;

void dalay(unsigned int time)
{

time=time-10;
time=time/6;
while(time!=0)time--;
}

uchar SPI_RW(uchar byte)
{
uchar bit_ctr;
for(bit_ctr=0;bit_ctr<8;bit_ctr++)
{
MOSI=byte&0x80;
byte=(byte<<1);
SCK=1;
byte|=MISO;
SCK=0;
}
}

uchar SPI_RW_Reg(uchar reg,uchar value)
{
uchar status;
CSN=0;
status=SPI_RW(reg);
SPI_RW(value);
CSN=1;
return(status);
}

uchar SPI_RW_Buf(uchar reg,uchar *pBuf,uchar bytes)
{
uchar status,byte_ctr;
CSN=0;
status=SPI_RW(reg);
for(byte_ctr=0;byte_ctr<bytes;byte_ctr++)
SPI_RW(*pBuf++);
CSN=1;
return(status);
}

void nRF24L01_TxPacket(uchar*tx_buf)
{
CE=0;
SPI_RW_Buf(0xa0,tx_buf,0x08);
SPI_RW_Reg(0x20,0x0e);
CE=1;
dalay(20);
CE=0;
}

void Config(void)
{
CE=0;
CSN=1;
SCK=0;
CE=0;
SPI_RW_Reg(0x20,0x0f);
SPI_RW_Reg(0x21,0x01);
SPI_RW_Reg(0x22,0x01);
SPI_RW_Reg(0x23,0x02);
SPI_RW_Reg(0x24,0x1a);
SPI_RW_Reg(0x25,0);
SPI_RW_Reg(0x26,0x07);
SPI_RW_Reg(0x31,0x08);
SPI_RW_Buf(0x30,pb,0x04);
SPI_RW_Buf(0x2a,pb,0x04);
}

void main(void)
{
dalay(60000);
dalay(60000);
Config();
while(1)
{
nRF24L01_TxPacket(pa);
dalay(2000);
}
}

我在模块的各个引脚都检查了一遍,电路应该没有问题

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top