This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USART fails in EXTI Interrupt

I have faced another strange thing today:
inside ISR of EXTI I wanted to send some character to USART, but I found that program halts there, after eliminating the commands regarding USART I found that program waits to reset USART_FLAG_TXE, but the flag remains in set mode. when I eliminated below command, program runs forward how ever just the last character transferred.

while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)


Why TXE flag could not become reset after transfer of the character?!

Parents
  • TXE will go High if the buffer is empty, it may go low briefly (1-2 baud clocks) after you send a character if the shift register is empty too, if it's busy then it might remain low for 8-10 baud clocks. If the USART is giving a problem make sure it's clocked properly. Don't look at in the debugger, as there are interactions between SR and DR registers.

    You should check TXE *before* sending characters, not after. Ideally you don't want to be spinning for microseconds or milliseconds within an interrupt handler. Perhaps you could buffer the output data, and manage it's output in the USART TXE interrupt?

Reply
  • TXE will go High if the buffer is empty, it may go low briefly (1-2 baud clocks) after you send a character if the shift register is empty too, if it's busy then it might remain low for 8-10 baud clocks. If the USART is giving a problem make sure it's clocked properly. Don't look at in the debugger, as there are interactions between SR and DR registers.

    You should check TXE *before* sending characters, not after. Ideally you don't want to be spinning for microseconds or milliseconds within an interrupt handler. Perhaps you could buffer the output data, and manage it's output in the USART TXE interrupt?

Children