Hi! Why stm32F103ZET use serial port can't receive and send data?
The system has been in smooth operation when configuration with USART1 program. The data's receiving and sending are very good. But it went wrong when I replaced usart1 instead of usart2.
Serial port is not working properly. I don't know what's wrong. Please give me some suggestions.Thank you.
USART_InitStruct.USART_BaudRate = 115200;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStruct.USART_Parity = USART_Parity_No;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
NVIC_InitStruct.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
if(USART_GetFlagStatus(USART2, USART_IT_RXNE) != RESET)
data = USART_ReceiveData(USART2);
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) != SET);
You're posting C code that isn't related to Espruino - you should contact ST Microelectronics who make the chips at http://st.com, or you might have some luck posting on http://stackoverflow.com/
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem