I'm trying to get UART working on a STM32F0 part and can't figure out the interrupts. According to the reference manual
Bit 7 TXE: Transmit data register empty
This bit is set by hardware when the content of the USARTx_TDR register has been
transferred into the shift register. It is cleared by a write to the USARTx_TDR register.
An interrupt is generated if the TXEIE bit =1 in the USARTx_CR1 register.
However, I can never see the TXE flag clear. Here is what I have in my IRQ Handler:
if(USART_GetITStatus(EVAL_COM1, USART_IT_TXE) != RESET)
{
/* Write one byte to the transmit data register */
if (TxBuffer[TxCount] != '\0')
{
USART_SendData(EVAL_COM1, TxBuffer[TxCount++]);
}
//else{
// USART_ITConfig(EVAL_COM1, USART_IT_TXE, DISABLE);
//}
}
Unless I uncomment the else statement, the send interrupt keeps triggering endlessly even after I stop sending bytes to the TDR. Is there a way to stop the interrupts without disabling them? Or do I need to re-enable every time I want to send something?