因为中断方式已经被占用了,所以就用循环方式接收数据,但是总是收不到,不知道是怎么回事,不知道哪里错了,现附上程序,大神们,帮小弟看看,急急急。USART_ClearFlag(USART3,USART_FLAG_RXNE);
UART_PutStr(USART3,ReplyForHandshake,29);
// Delay_ms(0x1500);
USART_RceStr(USART3,LowPowerData);
Delay_ms(60);
USART_ClearFlag(USART3,USART_FLAG_RXNE);
UART_PutStr(USART3,PowerCollect,11);
USART_RceStr(USART3,LowPowerData1);
这是接收函数程序段:
void USART_RceStr(USART_TypeDef* USARTx,uint8_t *RceStr)
{
uint8_t m = 0;
uint8_t RceData = 0;
uint8_t flag_Rce = 0;
while(USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) != SET);
while(USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) != RESET)
{
RceData = USART_ReceiveData(USARTx);
if(RceData == 0x6b)
{
RceStr[0] = RceData;
flag_Rce = 1;
}
if(RceStr[0] == 0x6b&&flag_Rce == 1)
{
RceStr[m++] = USART_ReceiveData(USARTx);
}
if(m >= 11)
{
m = 0;
flag_Rce = 0;
break;
}
}
} |