Question
F207 USART TXE issues
Posted on June 04, 2012 at 16:29
Hello.
I am seeing issues witht he TXE interrupt firing for no reason. Here is my IRQ handler: #define COM3 USART3void USART3_IRQHandler(void)
{ uint8_t x;// Get Byte from DR in case of Overrun
if ( COM3->SR & USART_FLAG_ORE ) { x = COM3->DR; }if ( COM3->SR & USART_FLAG_RXNE )
{ while ( COM3->SR & USART_FLAG_RXNE ) { DIL_Serial_RX_Receive ( PROTOCOL_PORT ); } } else if ( COM3->SR & USART_FLAG_TXE ) { DIL_Serial_TX_Send ( PROTOCOL_PORT ); } } The snippit of the write function my ISR calls:case PROTOCOL_PORT:
if ( Com3TxQue.Head != Com3TxQue.Tail ) { COM3->DR = *Com3TxQue.Tail;if ( ++Com3TxQue.Tail == &Com3TxQue.Buff[COM3_TX_BUFFER_SIZE] )
{ Com3TxQue.Tail = &Com3TxQue.Buff[0]; }Com3TxQue.BytesOut--;
Com3TxQue.Flag &= ~FULL;
} else { // Disable the TX enable line GPIO_ResetBits ( RS485_TX_EN_GPIO_PORT, RS485_TX_EN_PIN );// Disable TX
USART_ITConfig ( COM3, USART_IT_TXE, DISABLE ); USART3->CR1 &= !USART_CR1_TXEIE; } Can anyone explain why this interrupt would fire if there is no RX data and TXEIE in CR1 is reset? I have read about a delay being needed before disabling the TXEIE flag and have tried a double for loops before disabling with no avail. This does not happen at run time, but after a few seconds of running and receieving packets. Anyone with similar problems, ideas, solutions? Thanks.