2016-07-16 12:55 AM
Hello!
I'm working on UART comunication between stm32f407 and PC. I want to transmit 4 character via ''senddata()'' function shown below.USART_SendData(USART1,'D');while(USART_GetFlagStatus(USART1, USART_FLAG_TC)==RESET);USART_SendData(USART1,'A');while(USART_GetFlagStatus(USART1, USART_FLAG_TC)==RESET);USART_SendData(USART1,'T');while(USART_GetFlagStatus(USART1, USART_FLAG_TC)==RESET);USART_SendData(USART1,'A');while(USART_GetFlagStatus(USART1, USART_FLAG_TC)==RESET); the problem is that when i wait for TC flag after each send, it won't change i mean it remains low. Therefore, the program is stuck in the while loop. how can i become sure of a transmit completion? isn't it the right way? According to the user manual file (Page 749-Fig.249), TC is not set until the last data is sent. how can i use it?when i remove while loops the program works fine but it only sends the last character to the PC.(usart1 is configured truly.)2016-07-16 04:48 AM
The processor is running much faster.than the USART, you should front wait on TXE rather than back wait on TC.
If you have the debugger displaying USART SR it will interfere with TC and RXNE2016-07-18 02:53 AM
clive1 is telling you to do this:
USART_SendData(USART1,c); while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);