请各位大神帮忙看下,这个两个发送,接收程序那里出错了
STC12C5A60S2
单片机发射程序
/*******************************************************************************************/
#include "hmi_driver.h"
#include "hmi_user_uart.h"
#include "cmd_process.h"
#include "stdio.h"
#include "DefineID.c"
#include "main.h"
#include "uli
tity.h"
#include "string.h"
#include "nRF905.h"
#include "intrins.h"
#define WC 0x00
#define RC 0x10
#define WTP 0x20
#define RTP 0x21
#define WTA 0x22
#define RTA 0x23
#define RRP 0x24
/*******************************************************************************************/
uchar senddata1[4]={0};
typedef struct RFConfig
{
uchar n;
uchar buf[10];
}RFConfig;
code RFConfig RxTxConf =
{
0x00,//配置命令
0x4c,//CH_NO,配置频段在430MHZ
0x0c,//输出功率为10db,不重发,节电为正常模式
0x44,//地址宽度设置,为4字节
0x04, 0x04, //接收发送有效数据长度为4字节
0xcc, 0xcc, 0xcc,0xc, //接收地址
0x58 //CRC充许,8位CRC校验,外部时钟信号不使能,16M晶振
};
code Tx_add[]={0x12,0x34,0x56,0x78};
uchar bdata DATA_BUF;
sbit flag =DATA_BUF^7;
sbit flag1 =DATA_BUF^0;
/*******************************************************************************************/
sbit TX_EN =P0^0;
sbit TRX_CE =P0^1;
sbit PWR_UP =P0^2;
sbit MISO =P0^3;
sbit MOSI =P0^4;
sbit SCK =P0^5;
sbit CSN =P0^6;
sbit AM =P2^1;
sbit DR =P2^2;
sbit CD =P2^0;
/*******************************************************************************************/
void Config905(void);
void SpiWrite(uchar);
uchar SpiRead(void);
/*******************************************************************************************/
void delay700us(void)
{
unsigned char a,b;
for(b=600;b>0;b--)
for(a=9;a>0;a--);
_nop_();
}
void delay100us(void)
{
unsigned char a,b;
for(b=78;b>0;b--)
for(a=2;a>0;a--);
_nop_();
}
void nRF_init()
{
CSN=1;
SCK=0;
DR=1;
AM=1;
PWR_UP=1;
TRX_CE=0;
TX_EN=0;
//================
Config905();
SetTxMode();
}
void Config905(void)
{
uchar i;
CSN=0;
SpiWrite(WC);
for (i=0;i<RxTxConf.n;i++)
{
SpiWrite(RxTxConf.buf[i]);
}
CSN=1;
}
void SpiWrite(uchar byte)
{
uchar i;
DATA_BUF=byte;
for (i=0;i<8;i++)
{
if (flag)
MOSI=1;
else
MOSI=0;
SCK=1;
DATA_BUF=DATA_BUF<<1;
SCK=0;
}
}
uchar SpiRead(void)
{
uchar i;
for (i=0;i<8;i++)
{
DATA_BUF=DATA_BUF<<1;
SCK=1;
if (MISO)
flag1=1;
else
flag1=0;
SCK=0;
}
return DATA_BUF;
}
void TxPacket(uchar TxBuf[],uchar n)
{
uchar i;
CSN=0;
SpiWrite(WTP);
for (i=0;i<n;i++)
{
SpiWrite(TxBuf[i]);
}
CSN=1;
delay100us();
CSN=0;
SpiWrite(WTA);
for (i=0;i<4;i++)
{
SpiWrite(Tx_add[i]);
}
CSN=1;
TRX_CE=1;
delay100us();
TRX_CE=0;
}
void RxPacket(uchar RxBuf[],uchar n)
{
uchar i;
TRX_CE=0;
CSN=0;
SpiWrite(RRP);
for (i=0;i<n;i++)
{
RxBuf[i]=SpiRead();
}
CSN=1;
while(DR||AM);
TRX_CE=1;
}
void SetTxMode(void)
{
TX_EN=0;
TRX_CE=1;
delay700us();
}
void SetRxMode(void)
{
TX_EN=0;
TRX_CE=1;
delay700us();
}
void main(void)
{
senddata1[0]=0x1f;
senddata1[1]=0xff;
senddata1[2]=0xff;
senddata1[3]=0xff;
nRF_init();
SetTxMode();
while(1)
{
TxPacket(senddata1,4);
delay_ms(3600);
}
}
ATmega16接收程序
#include "nRF905.h"
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//uchar CodeEditor[]={0x1e,0x1d,0x1c,0x1b,0x1a,0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10};
#define SET_1(a,b) a|=(1<<b)
#define CLE_0(a,b) a&=~(1<<b)
//端口初始化
//---------------------------------模式控制定义---------------------------------
//#define nrf905_TX_EN PB2 //输出1
#define Hign_nrf905_TX_EN PORTB |= (1 < PB2);
#define Low_nrf905_TX_EN PORTB &= ~(1 < PB2);
//#define nrf905_TRX_CE PB3 //输出1
#define Hign_nrf905_TRX_CE PORTB |= (1 < PB3);
#define Low_nrf905_TRX_CE PORTB &= ~(1 < PB3);
//#define nrf905_PWR PB1 //输出1
//#define Hign_nrf905_PWR PORTB |= (1 < PB1);
//#define Low_nrf905_PWR PORTB &= ~(1 < PB1);
//--------------------------------NRF905-SPI口接口定义--------------------------
//#define nrf905_MISO PB6 //输入0
#define nrf905_MISO PORTB |= (1 < PB4);
#define nrf905_MISO PORTB &= ~(1 < PB4);
#define Read_nrf905_MISO PINB & (1 < PB4);
//#define nrf905_MOSI PB5 //输出1
#define Hign_nrf905_MOSI PORTB |= (1 < PB5);
#define Low_nrf905_MOSI PORTB &= ~(1 < PB5);
//#define nrf905_SCK PB7 //输出1
#define Low_nrf905_SCK PORTB &= ~(1 < PB7);
//#define nrf905_CSN PB4 //输出1
#define Hign_nrf905_CSN PORTB |= (1 < PB4);
#define Low_nrf905_CSN PORTB &= ~(1 < PB4);
//-------------------------------NRF905状态输出口-------------------------------
//#define nrf905_CD PD4 //输入0
//#define Hign_nrf905_CD PORTD |= (1 < PD4);
//#define Low_nrf905_CD PORTD &= ~(1 < PD4);
//#define Read_nrf905_CD PINB & (1 < PD4);
//#define nrf905_AM PB3 //输入0
//#define Hign_nrf905_AM PORTB |= (1 < PB3);
//#define Low_nrf905_AM PORTB &= ~(1 < PB3);
//#define Read_nrf905_AM PINB & (1 < PB3);
//#define nrf905_DR PC7 //输入0
#define Hign_nrf905_DR PORTC |= (1 < PC7);
#define Low_nrf905_DR PORTC &= ~(1 < PC7);
#define Read_nrf905_DR PINC & (1 < PC7);
//----------------------------------NRF905-SPI指令------------------------------
#define WC 0x00
#define RRC 0x10
#define WTP 0x20
#define RTP 0x21
#define WTA 0x22
#define RTA 0x23
#define RRP 0x24
//uchar DATA_BUF;
//---------------------------------发送数据-------------------------------------
uchar TxRxBuffer[32];
//----------------------------------接收地址------------------------------------
uchar TxAddress[4]={0xcc,0xcc,0xcc,0xcc };
//----------------------------------寄存器配置----------------------------------
uchar RFConf[11]=
{
0x00, //配置命令//
0x4c, //CH_NO,配置频段在430MHZ
0x0C, //输出功率为10db,不重发,节电为正常模式
0x44, //地址宽度设置,为4字节
0x04,0x04, //接收发送有效数据长度为32字节
0xCC,0xCC,0xCC,0xCC, //接收地址
0x58, //CRC充许,8位CRC校验,外部时钟信号不使能,16M晶振
};
//----------------------------------NRF905函数申明------------------------------
void Delay(uint x); //延时子程序
void Spi_initial(); //SPI初始化
uchar SpiReadSpiWrite(unsigned char cData); //SPI读写子程序
void nRF_init(void); //nRF_init初始化
void Config905(void); //NRF905初始化子程序
void TxPacket(void);
void SetTxMode(void); //数据发送
void SetRxMode(void); //
void TX(void);
unsigned char CheckDR(void);
void RxPacket(void);
void RX(void);
//-------------------------------串口函数申明-----------------------------------
void StartUART(void);
void R_S_Byte(uchar R_Byte);
//----------------------------------100us延时子程序-----------------------------
void Delay(uint x)
{
uint i;
while(x--)
for(i=0;i<80;i++);
}
//----------------------------------SPI初始化-----------------------------------
void Spi_initial()
{
SPCR = (1<<SPE)|(1<<MSTR)|(0<<CPOL)|(0<<SPR0);// 主机模式,fck/16, SPI方式0
//* 设置MOSI 和SCK 为输出,其他为输入 */
//DDRB = (1<<PB5)|(1<<PB7);
/* 使能SPI 主机模式,设置时钟速率为fck/16 */
//SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}
//---------------------------------SPI读写程序----------------------------------
uchar SpiReadSpiWrite(unsigned char cData)
{
//SPDR = cData;
while(!(SPSR & (1<<SPIF) )); // 等待SPI发送完毕
//{};
return SPDR;
}
//--------------------------------nRF_init状态初始化--------------------------------
void nRF_init(void)
{
Hign_nrf905_CSN; // SPI使能
Low_nrf905_SCK;
Low_nrf905_DR; // DR=0
//Low_nrf905_AM; // AM=0
//Low_nrf905_CD; // CD=0
//Hign_nrf905_PWR; // PWR=1
Low_nrf905_TRX_CE; // nrf905_TRX_CE=0
Low_nrf905_TX_EN ; // nrf905_TX_EN=0
}
//--------------------------------NRF905寄存器初始化函数------------------------
void Config905(void)
{
uchar i;
Low_nrf905_CSN; //SPI使能
Delay(1);
for (i=0;i<11;i++) //碞RF905配置字
{
SpiReadSpiWrite(RFConf[i]);
}
Hign_nrf905_CSN; // Disable Spi
}
//--------------------------------NRF905待发数据打包----------------------------
void TxPacket()
{
uchar i;
Low_nrf905_CSN; // 使能Spi,允许对nrf905进行读写操作
Delay(1);
SpiReadSpiWrite(WTP); // 写数据前先写写数据命令
for (i=0;i<32;i++)
{
SpiReadSpiWrite(TxRxBuffer[i]); // 待发送的32字节数据
}
Hign_nrf905_CSN;
Delay(1); // 关闭Spi,不允许对nrf905进行读写操作
Low_nrf905_CSN; // 使能Spi
SpiReadSpiWrite(WTA); // 写地址前首先先写地址命令
for (i=0;i<4;i++) //写入4 bytes 接收地址
{
SpiReadSpiWrite(TxAddress[i]);
}
Hign_nrf905_CSN; // 关闭Spi
Hign_nrf905_TRX_CE; // Set TRX_CE high,start Tx data transmission
Delay(1); // 等待DR变高
Low_nrf905_TRX_CE; // 设置TRX_CE=0
}
//------------------------------设置发送模式------------------------------------
void SetTxMode(void)
{
Low_nrf905_TRX_CE; //
Hign_nrf905_TX_EN; //发送使能
Delay(70); // delay for mode change(>=650us)
}
//------------------------------设置接收模式激发--------------------------------
void SetRxMode(void)
{
Low_nrf905_TX_EN;
Hign_nrf905_TRX_CE;
Delay(70); // delay for mode change(>=650us)
}
//------------------------------发送数据----------------------------------------
void TX(void)
{
SetTxMode(); // Set nRF905 in Tx mode
TxPacket(); // Send data by nRF905
}
//-----------------------------判断是否收到数据---------------------------------
unsigned char CheckDR(void) //检查是否有新数据传入
{
if (PINC & (1 < PC7))
{
return 1; //收到数据
}
else
{
return 0;
}
}
//-----------------------------------读接收数据包-------------------------------
void RxPacket() //读数据
{
uchar i;
Low_nrf905_TRX_CE;
Low_nrf905_CSN; // 使能SPI
Delay(1);
SpiReadSpiWrite(RRP); // 写入数据接收缓冲区数据命令
for (i = 0 ;i<4;i++)
{
TxRxBuffer[i]=SpiReadSpiWrite(0); // 读取数据接收缓冲区数据
}
Hign_nrf905_CSN;
Delay(2); //
Hign_nrf905_TRX_CE;
}
//--------------------------------设置接收模式----------------------------------
void RX(void)
{
SetRxMode(); //设置NRF905接收模式
while (CheckDR()==0); //等待接收完成
RxPacket(); //读取接收数据缓冲区
Delay(70);
}
//-------------------------------串口初始化-------------------------------------
void StartUART(void)
{
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x06;
UBRRL=0x33;
UBRRH=0x00;
UCSRA=UCSRA|0x08;
}
//------------------------------串口发送----------------------------------------
void R_S_Byte(uchar R_Byte)
{
UDR= R_Byte;
}
//端口初始化
void port_init(void)
{
PORTA = 0x00;
DDRA = 0xFF;//PA全部位设置为输出
PORTB = 0x00;
DDRB = 0xFF;//PB全部位设置为输出
PORTC = 0xff;
DDRC = 0x00;//PC全部位设置为输入
PORTD = 0x00;
DDRD = 0xFC;
}
main ()
{
port_init();
Spi_initial(); //SPI初始化
nRF_init(); //nRF_init初始化
Config905();
while(1)
{
uchar K1;
K1=((PINC&0x7c)>>2);
//uchar i;
//K1=0x04;
//TxRxBuffer[0]=0X1f;
RX();
if(1)
{
//TxRxBuffer[1]=0Xff;
//TxRxBuffer[2]=0Xff;
if(TxRxBuffer[1]&0x01) SET_1(PORTA,7);
else CLE_0(PORTA,7);
if(TxRxBuffer[1]&0x02) SET_1(PORTA,6);
else CLE_0(PORTA,6);
if(TxRxBuffer[1]&0x04) SET_1(PORTA,5);
else CLE_0(PORTA,5);
if(TxRxBuffer[1]&0x08) SET_1(PORTA,4);
else CLE_0(PORTA,4);
if(TxRxBuffer[1]&0x10) SET_1(PORTA,3);
else CLE_0(PORTA,3);
if(TxRxBuffer[1]&0x20) SET_1(PORTA,2);
else CLE_0(PORTA,2);
if(TxRxBuffer[1]&0x40) SET_1(PORTA,1);
else CLE_0(PORTA,1);
if(TxRxBuffer[1]&0x80) SET_1(PORTA,0);
else CLE_0(PORTA,0);
if(TxRxBuffer[2]&0x01) SET_1(PORTD,7);
else CLE_0(PORTD,7);
if(TxRxBuffer[2]&0x02) SET_1(PORTD,6);
else CLE_0(PORTD,6);
if(TxRxBuffer[2]&0x04) SET_1(PORTD,5);
else CLE_0(PORTD,5);
if(TxRxBuffer[2]&0x08) SET_1(PORTD,4);
else CLE_0(PORTD,4);
if(TxRxBuffer[2]&0x10) SET_1(PORTD,3);
else CLE_0(PORTD,3);
if(TxRxBuffer[2]&0x20) SET_1(PORTD,2);
else CLE_0(PORTD,2);
if(TxRxBuffer[2]&0x40) SET_1(PORTB,0);
else CLE_0(PORTB,0);
if(TxRxBuffer[2]&0x80) SET_1(PORTB,1);
else CLE_0(PORTB,1);
}
}
}
那怎样进行定位调试,我只有一个万用表,NRF905的发射和接收程序我在软件里单步调试都可以进入每个的子函数,烧进IC里,在板上不知怎样进行调试,不清楚是那个出现了问题,要不你帮我看下是那个程序出现问题了
接收的程序
#include <avr/io.h>
#define uint unsigned int
#define uchar unsigned char
#define SET_1(a,b) a|=(1<<b)
#define CLE_0(a,b) a&=~(1<<b)
//---------------------------------模式控制定义---------------------------------
#define IO_Output_TX_EN() DDRB |= 0x04 //输出1
#define IO_Output_TRX_CE() DDRB |=0x80//输出1
#define IO_Output_MOSI() DDRB |=0x20 //输出1
#define IO_Output_SCK() DDRB |=0x80 //输出1
#define IO_Output_CSN() DDRB |=0x01 //输出1
#define IO_Input_DR() DDRC &= ~0x80 //输入0
#define IO_Input_MISO() DDRB &= ~0x40//输入0
#define TX_EN_1 PORTB |= (1 << PB2)
#define TX_EN_0 PORTB &= ~(1 << PB2)
#define TRX_CE_1 PORTB |= (1 << PB3)
#define TRX_CE_0 PORTB &= ~(1 << PB3)
//--------------------------------NRF905-SPI口接口定义--------------------------
//#define MISO (PINB&BIT(6))
//#define nrf905_MISO PORTB |= (1 << PB6);
//#define nrf905_MISO PORTB &= ~(1 << PB6);
#define MISO PINB &(1 << PB6)
#define MOSI_1 PORTB |= (1 << PB5)
#define MOSI_0 PORTB &= ~(1 << PB5)
#define SCK_1 PORTB |= (1 << PB7)
#define SCK_0 PORTB &= ~(1 << PB7)
#define CSN_1 PORTB |= (1 << PB4)
#define CSN_0 PORTB &= ~(1 << PB4)
//-------------------------------NRF905状态输出口-------------------------------
#define DR_1 PORTC |= (1 << PC7)
#define DR_0 PORTC &= ~(1 << PC7)
#define Read_nrf905_DR PINC&0X80
//----------------------------------NRF905-SPI指令------------------------------
#define WC 0x00
#define RRC 0x10
#define WTP 0x20
#define RTP 0x21
#define WTA 0x22
#define RTA 0x23
#define RRP 0x24
/*******************************************************************************************/
uchar TxRxBuf[4];
typedef struct RFConfig
{
uchar n;
uchar buf[10];
}RFConfig;
RFConfig RxTxConf =
{
10,
0x4c,
0x0c,
0x44,
0x04, 0x04,
0xcc, 0xcc, 0xcc,0xc,
0x58
};
uchar Tx_add[]={0x12,0x34,0x56,0x78};
uchar DATA_BUF;
#define DATA7 (DATA_BUF&0x80)!= 0
#define DATA0 (DATA_BUF&0x01)!= 0
/*******************************************************************************************/
void Config905(void);
void SpiWrite(uchar);
uchar SpiRead(void);
/*******************************************************************************************/
//----------------------------------100us延时子程序-----------------------------
void Delay(uint x)
{
uint i;
while(x--)
for(i=0;i<110;i++);
}
//----------------------------------10us延时子程序-----------------------------
void Delay10us(uint x)
{
uint i;
while(x--)
for(i=0;i<11;i++);
}
void SpiWrite(unsigned char send)
{
unsigned char i;
DATA_BUF=send;
for (i=0;i<8;i++)
{
if (DATA7) //总是发送最高位
{
MOSI_1;
}
else
{
MOSI_0;
}
SCK_1;
DATA_BUF=DATA_BUF<<1;
SCK_0;
}
}
//---------------------------------------------------SPI读函数-----------------------------------------------------
unsigned char SpiRead(void)
{
unsigned char j;
for (j=0;j<8;j++)
{
DATA_BUF=DATA_BUF<<1;
SCK_1;
if(MISO) //读取最高位,保存至最末尾,通过左移位完成整个字节
{
DATA_BUF|=0x01;
}
else
{
DATA_BUF&=~0x01;
}
SCK_0;
}
return DATA_BUF;
}
void nRF_init()
{
IO_Output_TX_EN();
IO_Output_TRX_CE();
IO_Output_MOSI();
IO_Output_SCK();
IO_Output_CSN();
IO_Input_DR();
IO_Input_MISO();
CSN_1;
SCK_0;
//DR_1;
//AM=1;
//PWR_UP=1;
TRX_CE_0;
TX_EN_0;
//================
//Config905();
//SetTxMode();
}
//-----------------------------------------------------初始化寄存器-----------------------------------------
void Config905(void)
{
uchar i;
CSN_0;
SpiWrite(WC);
for (i=0;i<RxTxConf.n;i++)
{
SpiWrite(RxTxConf.buf);
}
CSN_1;
}
void RxPacket(uchar RxBuf[],uchar n)
{
uchar i;
TRX_CE_0;
CSN_0;
SpiWrite(RRP);
for (i=0;i<n;i++)
{
RxBuf=SpiRead();
}
CSN_1;
TRX_CE_1;
while(~(PINC&0X80));
}
void SetRxMode(void)
{
TX_EN_0;
TRX_CE_1;
Delay(9);
}
//端口初始化
void port_init(void)
{
PORTA = 0x00;
DDRA = 0xFF;//PA全部位设置为输出
PORTB = 0x00;
DDRB = 0xBF;//PB全部位设置为输出
PORTC = 0x7f;
DDRC = 0x00;//PC全部位设置为输入
PORTD = 0x00;
DDRD = 0xFC;
}
void main()
{
port_init();
nRF_init();
Config905();
while(1)
{
uchar K1;
K1=((PINC&0x7c)>>2);
//uchar i;
//K1=0x04;
//TxRxBuffer[0]=0X1f;
RxPacket(TxRxBuf,4);
PORTA=TxRxBuf[1];
//PORTA=0XFF;
}
}
发射的程序
#include "STC12C5A60S2.H"
#include "stdio.h"
#include "string.h"
#include "intrins.h"
#include "nRF905.h"
#define uint unsigned int
#define uchar unsigned char
#define WC 0x00
#define RC 0x10
#define WTP 0x20
#define RTP 0x21
#define WTA 0x22
#define RTA 0x23
#define RRP 0x24
/*******************************************************************************************/
uchar TxRxBuf[4];
typedef struct RFConfig
{
uchar n;
uchar buf[10];
}RFConfig;
code RFConfig RxTxConf =
{
10,
0x4c,
0x0c,
0x44,
0x04, 0x04,
0xcc, 0xcc, 0xcc,0xc,
0x58
};
code Tx_add[]={0x12,0x34,0x56,0x78};
uchar bdata DATA_BUF;
sbit flag =DATA_BUF^7;
sbit flag1 =DATA_BUF^0;
/*******************************************************************************************/
sbit TX_EN =P0^0;
sbit TRX_CE =P0^1;
sbit PWR_UP =P0^2;
sbit MISO =P0^3;
sbit MOSI =P0^4;
sbit SCK =P0^5;
sbit CSN =P0^6;
sbit AM =P2^1;
sbit DR =P2^2;
sbit CD =P2^0;
/*******************************************************************************************/
void Config905(void);
void SpiWrite(uchar);
uchar SpiRead(void);
/*******************************************************************************************/
void delay700us(void)
{
unsigned char a,b;
for(b=184;b>0;b--)
for(a=9;a>0;a--);
_nop_();
}
void delay100us(void)
{
unsigned char a,b;
for(b=78;b>0;b--)
for(a=2;a>0;a--);
_nop_();
}
void nRF_init()
{
CSN=1;
SCK=0;
DR=1;
AM=1;
PWR_UP=1;
TRX_CE=0;
TX_EN=0;
//================
Config905();
SetTxMode();
}
void Config905(void)
{
uchar i;
CSN=0;
SpiWrite(WC);
for (i=0;i<RxTxConf.n;i++)
{
SpiWrite(RxTxConf.buf);
}
CSN=1;
}
void SpiWrite(uchar byte)
{
uchar i;
DATA_BUF=byte;
for (i=0;i<8;i++)
{
if (flag)
MOSI=1;
else
MOSI=0;
SCK=1;
DATA_BUF=DATA_BUF<<1;
SCK=0;
}
}
uchar SpiRead(void)
{
uchar i;
for (i=0;i<8;i++)
{
DATA_BUF=DATA_BUF<<1;
SCK=1;
if (MISO)
flag1=1;
else
flag1=0;
SCK=0;
}
return DATA_BUF;
}
void TxPacket(uchar TxBuf[],uchar n)
{
uchar i;
CSN=0;
SpiWrite(WTP);
for (i=0;i<n;i++)
{
SpiWrite(TxBuf);
}
CSN=1;
delay100us();
CSN=0;
SpiWrite(WTA);
for (i=0;i<4;i++)
{
SpiWrite(Tx_add);
}
CSN=1;
TRX_CE=1;
delay100us();
TRX_CE=0;
}
void RxPacket(uchar RxBuf[],uchar n)
{
uchar i;
TRX_CE=0;
CSN=0;
SpiWrite(RRP);
for (i=0;i<n;i++)
{
RxBuf=SpiRead();
}
CSN=1;
while(DR||AM);
TRX_CE=1;
}
void SetTxMode(void)
{
TX_EN=1;
TRX_CE=0;
delay700us();
}
void SetRxMode(void)
{
TX_EN=0;
TRX_CE=1;
delay700us();
}
void main(void)
{
nRF_init();
//Config905();
//while(1);
if(1)
{
TxRxBuf[0]=0xff;
TxRxBuf[1]=0xff;
TxRxBuf[2]=0xff;
TxRxBuf[3]=0xff;
//SetTxMode();//Set nRF905 in Tx mode
TxPacket(TxRxBuf,4);// Send data by nRF905
}
//while(1);
}
一周热门 更多>