初级会员

- 积分
- 81
- 金钱
- 81
- 注册时间
- 2016-8-11
- 在线时间
- 17 小时
|
10金钱
编译器表示没错误 没警告 我想知道代码有没有错误 为什么我效果实现不了
#include "stm32f10x.h"
#include "bsp_usart4.h"
#include "bsp_usart2.h"
uint8_t Rxflag=0;
uint8_t ucTemp;
int main(void)
{
uint8_t ucaRxBuf[256];
uint16_t usRxCount;
UART4_Config();
USART2_Config();
Usart2_SendString("这是一个串口中断接收回显实验\n");
Usart2_SendString("输入数据并以回车键结束\n");
usRxCount = 0;
while(1)
{
if(Rxflag)
{
if (usRxCount < sizeof(ucaRxBuf))
{
ucaRxBuf[usRxCount++] = ucTemp;
}
else
{
usRxCount = 0;
}
/* 遇到换行字符,认为接收到一个命令 */
if (ucTemp == 0x0A) /* 换行字符 */
{
Usart2_SendStr_length(ucaRxBuf,usRxCount);
//Usart_SendString();
usRxCount = 0;
}
Rxflag=0;
}
}
}
void UART4_IRQHandler(void)
{
if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET)
{
Rxflag=1;
ucTemp = USART_ReceiveData(UART4);
}
}
|
|