串口中断函数如下:
void USART1_IRQHandler(void)
{
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
/* Read one byte from the receive data register */
RxBuffer[ RxCounter ] = USART_ReceiveData(USART1);
//如果接收的长度为0xfe或以上
if( RxCounter == 0x04 || '#'== RxBuffer[ RxCounter ] )
{
/* Disable the USART1 Receive interrupt */
USART_ITConfig(USART1, USART_IT_RXNE, DISABLE);
UartHaveData = 1;
}
RxCounter++;
}
}
主函数循环当中:
while (1)
{
Uart1_PutString("a");
Delay_Ms(1000);
/* Receive a string (Max RxBufferSize bytes) from the Hyperterminal ended by '\r' (Enter key) */
if( 1 == UartHaveData )
{
Uart1_PutString(RxBuffer);//Uart1_SendString( RxBuffer , RxCounter );
RxCounter = 0;
UartHaveData = 0;
// Enable USART1 Receive and Transmit interrupts
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
}
}
问题是这样的,当用串口调试助手发送的数据超过0x04时,串口调试助手不能正常的显示前面的0x04位;
如果我想让串口调试助手正常的显示前面发送的0x04位,应该怎么改,自己改了一下午还是不行,请高手指点
是不是的在那儿加一句检测接收数据非空标志位呢? |