模拟USART输出有问题,请大家帮忙看看
时间:10-02
整理:3721RD
点击:
int main(void)
{
unsigned char i,data;
USART_InitTypeDef USART_InitStructure;
RCC_Configuration();
GPIO_Configuration();
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl =USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1,ENABLE);
data = 'A';
for(i=0; i<10; i++)
{
USART_SendData(USART1,data);
data++;
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
}
}
我明明循环了10次,却只打印出了9个数据,原本想输出“ABCDEFGHIJ”,但是实际输出出来的是“ACDEFGHIJ”
{
unsigned char i,data;
USART_InitTypeDef USART_InitStructure;
RCC_Configuration();
GPIO_Configuration();
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl =USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1,ENABLE);
data = 'A';
for(i=0; i<10; i++)
{
USART_SendData(USART1,data);
data++;
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
}
}
我明明循环了10次,却只打印出了9个数据,原本想输出“ABCDEFGHIJ”,但是实际输出出来的是“ACDEFGHIJ”
