自己想用NRF24L01做一辆无线遥控的小车 现在在通信部分遇到了一点问题<br />
<br />
我把MINI开发板中的例程改了一点但是接收不到数据<br />
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true] int main(void)
{
u8 key,mode;
u16 t=0;
u8 adcx1[1]={0},adcx2[1]={0};
delay_init();
NVIC_Configuration();
uart_init(9600);
LED_Init();
LCD_Init();
KEY_Init();
NRF24L01_Init();
Adc_Init();
POINT_COLOR=RED;
LCD_ShowString(60,50,200,16,16,"Mini STM32");
LCD_ShowString(60,70,200,16,16,"NRF24L01 TEST");
LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,200,16,16,"2014/3/12");
while(NRF24L01_Check())
{
LCD_ShowString(60,130,200,16,16,"NRF24L01 Error");
delay_ms(200);
LCD_Fill(60,130,239,130+16,WHITE);
delay_ms(200);
}
LCD_ShowString(60,130,200,16,16,"NRF24L01 OK");
while(1)
{
key=KEY_Scan(0);
if(key==KEY1_PRES)
{
mode=1;
break;
}
t++;
if(t==100)LCD_ShowString(10,150,230,16,16,"KEY0:RX_Mode KEY1:TX_Mode");
if(t==200)
{
LCD_Fill(10,150,230,150+16,WHITE);
t=0;
}
delay_ms(5);
}
LCD_Fill(10,150,240,166,WHITE);
POINT_COLOR=BLUE;
if(mode==1)
{
LCD_ShowString(60,150,200,16,16,"NRF24L01 TX_Mode");
NRF24L01_TX_Mode();
while(1)
{
adcx1[0]=Get_Adc(ADC2,ADC_Channel_10)/32;
adcx2[0]=Get_Adc(ADC2,ADC_Channel_13)/32;
if(NRF24L01_TxPacket(adcx1)==TX_OK&&NRF24L01_TxPacket(adcx2)==TX_OK)
{
LCD_ShowString(60,170,239,32,16,"Sended DATA:");
LCD_ShowxNum(170,170,adcx1[0],4,16,0);
LCD_ShowxNum(170,190,adcx2[0],4,16,0);
}else
{
LCD_ShowString(60,170,239,32,16,"Send Failed ");
LCD_Fill(0,188,240,218,WHITE);
};
LED0=!LED0;
delay_ms(1500);
};
}
}
[/mw_shl_code]
</div>
<br />
<br />
<br />
<br />
下面是接受模块的<br />
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true]int main(void)
{
u8 key,mode;
u16 t=0;
u8 adcx1[1]={0},adcx2[1]={0};
delay_init();
NVIC_Configuration();
uart_init(9600);
LED_Init();
LCD_Init();
KEY_Init();
NRF24L01_Init();
POINT_COLOR=RED;
printf("Mini STM32\n");
printf("NRF24L01 TEST\n");
printf("ATOM@ALIENTEK\n");
printf("2014/3/12\n");
while(NRF24L01_Check())
{
printf("NRF24L01 Error\n");
delay_ms(1000);
printf(" \n");
delay_ms(1000);
}
printf("NRF24L01 OK");
while(1)
{
key=KEY_Scan(0);
if(key==KEY0_PRES)
{
mode=0;
break;
}
t++;
if(t==100)printf("KEY0:RX_Mode KEY1:TX_Mode\n");
if(t==200)
{
printf(" \n");
t=0;
}
delay_ms(5);
}
printf(" \n");
POINT_COLOR=BLUE;
if(mode==0)//RX????
{
printf("NRF24L01 RX_Mode\n");
printf("Received DATA:\n");
NRF24L01_RX_Mode();
while(1)
{
if(NRF24L01_RxPacket(adcx1)==0&&NRF24L01_RxPacket(adcx2)==0)
{
printf("RECEIVE:OK/n");
printf("adcx1:%s ",adcx1);
printf("adcx2:%s\n",adcx2);
}
}
}
}[/mw_shl_code]
</div>
<br />
<br />
<br />
<br /> |