单片机串口配置

2019-04-15 17:24发布

  /*串口参数配置*/ USART_InitStructure.USART_BaudRate = 115200; /*设置波特率为115200*/ USART_InitStructure.USART_WordLength = USART_WordLength_8b; /*设置数据位为8位*/ USART_InitStructure.USART_StopBits = USART_StopBits_1; /*设置停止位为1位*/ USART_InitStructure.USART_Parity = USART_Parity_No; /*无奇偶校验*/ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; /*没有硬件流控*/ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /*发送与接收*/ /*完成串口COM1的时钟配置、GPIO配置,根据上述参数初始化并使能*/ STM_EVAL_COMInit(COM1, &USART_InitStructure); 完成上述配置之后,单片机就会有串口打印了