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_Rx | USART_Mode_Tx;
//USART_InitStructure.USART_Clock = USART_Clock_Disable;
//USART_InitStructure.USART_CPOL = USART_CPOL_Low;
//USART_InitStructure.USART_CPHA = USART_CPHA_2Edge;
//USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
USART_Init(USART1, &USART_InitStructure);
USART_ClearFlag(USART1, USART_FLAG_TC);
/* Enable USART1 */
USART_Cmd(USART1, ENABLE);
USART_InitStructure2.USART_BaudRate = 2400;
USART_InitStructure2.USART_WordLength = USART_WordLength_8b;
USART_InitStructure2.USART_StopBits = USART_StopBits_1;
USART_InitStructure2.USART_Parity = USART_Parity_No;
USART_InitStructure2.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure2.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
//USART_InitStructure2.USART_Clock = USART_Clock_Disable;
//USART_InitStructure2.USART_CPOL = USART_CPOL_Low;
//USART_InitStructure2.USART_CPHA = USART_CPHA_2Edge;
//USART_InitStructure2.USART_LastBit = USART_LastBit_Disable;
USART_Init(USART2, &USART_InitStructure2);
USART_ClearFlag(USART2, USART_FLAG_TC);
/* Enable USART1 */
USART_Cmd(USART2, ENABLE);
这是串口初始化的函数配置
|