新手入门
- 积分
- 26
- 金钱
- 26
- 注册时间
- 2015-8-24
- 在线时间
- 0 小时
|
5金钱
<div>
代码是在stm32f103上利用nrf24l01模块发送数据(压力传感器的重物质量),但是串口什么都没有输出<img src="file://C:\Users\ADMINI~1\AppData\Local\Temp\E9BIPM$_`9}`VS07`VD9H1F.gif" />,跪求大神帮忙看下哪里有问题啊<img src="file://C:\Users\ADMINI~1\AppData\Local\Temp\T9QRV}V55@6B1SFLKDSC3LI.gif" /><br />
<img src="file://C:\Users\Administrator\AppData\Roaming\Tencent\Users\906697570\QQ\WinTemp\RichOle\N(4}7AH`HCOWEDNO4J_Q8DQ.png" /><br />
<img src="file://C:\Users\Administrator\AppData\Roaming\Tencent\Users\906697570\QQ\WinTemp\RichOle\L9)_${}E7KV]V)$@TI3JNZB.png" />int main(void)<br />
{ <br />
int i=0;<br />
long double M_Old,M_New,differ=0;<br />
<br />
u8 char2[30]="Transmit Succeed!\n";<br />
u8 char3[30]="Transmit Fail!\n"; <br />
u8 char5[30]="Data no change!\n";<br />
<br />
u8 TxBuf[8];<br />
<br />
delay_init(); //延时函数初始化 <br />
NVIC_Configuration(); //中断优先处理/<br />
uart_init(9600); //串口初始化为9600<br />
//LCD_Init(); //初始化LCD <br />
NRF24L01_Init(); //初始化NRF24L01 <br />
init();<br />
<br />
M_Old=SetM_Old();//M_Old,M_New存放初值NULLMASS<br />
M_New=M_Old;<br />
<br />
NRF24L01_TX_Mode(); //设置无线模块为发射<br />
delay_ms(500);<br />
<br />
while(1)<br />
{<br />
M_New=Count_Mass();<br />
differ=M_New-M_Old;<br />
<br />
FloatToStr1(M_New,TxBuf);<br />
<br />
if(differ>3||differ<-3) //数据波动在3g范围内不发送<br />
{<br />
M_Old=M_New;<br />
<br />
if(NRF24L01_TxPacket(TxBuf)==TX_OK)<br />
{ <br />
delay_ms(500);<br />
for(i=0;char2!='\0';i++) //如果发送成功,向串口发送"Transmit Succeed!\n"<br />
{<br />
USART_SendData(USART1, char2); <br />
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);<br />
} <br />
<br />
} <br />
<br />
else<br />
{<br />
delay_ms(500);<br />
for(i=0;char3!='\0';i++)//如果发送失败,//如果发送成功,向串口发送"Transmit Succeed!\n"<br />
{<br />
USART_SendData(USART1, char3); <br />
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
else //否则,向串口发送"Data no change!\n"<br />
{<br />
delay_ms(500);<br />
for(i=0;char5!='\0';i++)<br />
{<br />
USART_SendData(USART1, char5); <br />
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);<br />
}<br />
}<br />
<br />
delay_ms(500);<br />
<br />
} <br />
}<br />
</div> |
|