初级会员
- 积分
- 78
- 金钱
- 78
- 注册时间
- 2013-8-9
- 在线时间
- 0 小时
|
<div><div>今天用同事的2个NRF24L01找了个例程在板上试,主机发送数据,从机接受得到,但是主机里面调用函数u8 NRF_Tx_Dat(u8 *txbuf)里面卡住了,会不会是IRQ引脚问题呢? IRQ引脚我设置为上拉,理论上是发送和接受完后IRQ变低电平。<br />
<div> <span class="Apple-tab-span" style="white-space:pre;"> </span>SPI_RW_Reg(WRITE_REG1 + CONFIG, 0x0e); TX_mode()<br />
SPI_RW_Reg(WRITE_REG1 + CONFIG, 0x0f); RX_mode() </div>
<br />
原子哥,求不吝赐教。 <br />
<br />
<br />
u8 NRF_Tx_Dat(u8 *txbuf)</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>u8 state; </div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>NRF_CE_LOW();</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div> SPI_NRF_WriteBuf(WR_TX_PLOAD,txbuf,TX_PLOAD_WIDTH); //到这里发送都是正常的,但是我检测返回就是没有。</div>
<div><br />
</div>
<div> NRF_CE_HIGH();</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> <span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>while(NRF_Read_IRQ()!=0); <span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>state = SPI_NRF_ReadReg(STATUS); </div>
<div> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>SPI_NRF_WriteReg(NRF_WRITE_REG+STATUS,state); <span class="Apple-tab-span" style="white-space:pre;"> </span></div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>SPI_NRF_WriteReg(FLUSH_TX,NOP); </div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>if(state&MAX_RT) </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> return MAX_RT; </div>
<div><br />
</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>else if(state&TX_DS) </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> <span class="Apple-tab-span" style="white-space:pre;"> </span>return TX_DS;</div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span> else<span class="Apple-tab-span" style="white-space:pre;"> </span> </div>
<div><span class="Apple-tab-span" style="white-space:pre;"> </span>return ERROR; </div>
<div>} </div>
</div> |
|