初级会员
- 积分
- 96
- 金钱
- 96
- 注册时间
- 2012-11-30
- 在线时间
- 1 小时
|
5金钱
我用单片机做发送程序,检测到了发送完成标志位,但是在原子哥的MINISTM32板子上也没有接收到数据。。。<br />
<br />
<br />
<br />
主函数while(1)里面的程序段:
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true] NRFSetTxMode(TxDate); //·???
while(CheckACK()); //?ì????·?·????ê±?
[/mw_shl_code]
</div>
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true]//发送程序:[/mw_shl_code]
[mw_shl_code=c,true]/*****************NRF?è????·?????????·???????******************************/
void NRFSetTxMode(uchar *TxDate)
{//·???????
CE=0;
NRFWriteTxDate(W_REGISTER+TX_ADDR,TxAddr,TX_ADDR_WITDH);//???????÷????+???????·????????+???????·+???·?í??
NRFWriteTxDate(W_REGISTER+RX_ADDR_P0,TxAddr,TX_ADDR_WITDH);//?????????????è±????????¨??0???·??·??????·?à??
NRFWriteTxDate(W_TX_PAYLOAD,TxDate,TX_DATA_WITDH);//????????
/******?????????????÷????**************/
NRFWriteReg(W_REGISTER+EN_AA,0x00); // ?????????¨??0×???????
NRFWriteReg(W_REGISTER+EN_RXADDR,0x01); // ?????????¨??0
NRFWriteReg(W_REGISTER+SETUP_RETR,0x0a); // ×?????·????±????250us+86us??×?????·?10??
NRFWriteReg(W_REGISTER+RF_CH,0x40); // ?????????¨??0x40
NRFWriteReg(W_REGISTER+RF_SETUP,0x07); // ??????????1Mbps??·???????0dBm???????ù·??ó?÷????
NRFWriteReg(W_REGISTER+CONFIG,0x0e); // CRC??????16??CRC???é??????
CE=1;
Delay(5);//±???10us??????
}[/mw_shl_code]
</div>
应答信号检测程序:<br />
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true]/****************************?ì??????????******************************/
uchar CheckACK()
{ //????·???
sta=NRFReadReg(STATUS); // ·???×????????÷
SendChar(sta);
SendString("\r\n"); //接收到STATUS 寄存器的数据为2E...
if(TX_DS || MAX_RT) //·????ê±?????
{
NRFWriteReg(W_REGISTER+STATUS,0xff); // ????TX_DS?òMAX_RT????±ê??
CSN=0;
NRFSPI(FLUSH_TX);//????????FIFO ???????ü?????????á???????????????ó?????????ó????×?????
CSN=1;
return(0);
}
else
return(1);
}
/******************??????·???????????????????????RX????*********************/
//????????????
uchar NRFRevDate(uchar *RevDate)
{
uchar RevFlags=0;
sta=NRFReadReg(R_REGISTER+STATUS);//·????????ó????×????????÷
if(RX_DR) // ??????·???????????
{
CE=0; //SPI????
NRFReadRxDate(R_RX_PAYLOAD,RevDate,RX_DATA_WITDH);// ??RXFIFO????????
RevFlags=1; //?????????ê??±ê??
}
NRFWriteReg(W_REGISTER+STATUS,0xff); //???????????óRX_DR,TX_DS,MAX_PT????????1???¨????1??????????±ê
return(RevFlags);
}[/mw_shl_code]
</div>
<br /> |
最佳答案
查看完整内容[请看2#楼]
回复【9楼】两个嘴巴笑110:
---------------------------------
论坛搜索下吧,51发,STM32收,论坛有好多人问过,也做出来了的。你参考下他们的。
|