Electronic – TXE bit not reset in USART communication

armembeddedstm32

I am programming an STM32F2 Cortex M3 chip (reference manual here). Specifically, I want to transmit bits through the USART. Reading pages 620 and following, I understand that the TXE bit of the USART status register should be reset by hardware after writing data to the data register.

I have not been able to get the TXE to reset. It is set at bootup, and even after writing to the data register, it stays set.

The reason I'm reading the TXE bit is because I want to make sure that I'm not overwhelming the USART with transmit requests. How can I get the TXE bit to reset? Should the TXE bit be read in normal communication?

Best Answer

That SEEMS to be covered in the section labelled "Transmit and receive" about half way down. Viz (especially see bold.)

  • Before data can be sent, the transmitter must first be enabled by setting the USARTx_CR1_TE bit in USARTx_CR1. According to the reference manual, immediately after setting this bit, an idle frame will be sent automatically. I could not observe this when repeatedly clearing and setting the TE bit.

    Before sending a character to the data register, you should test the USARTx_SR_TXE bit.

    This bit indicates that data register holds data not yet sent to the TDR shift register.

    There is no need to directly set or clear the TXE flag, it is cleared when data is written to USARTx_DR and set when that data is transferred to the TDR. An interrupt can be connected to this bit if you want to be sending data under interrupt control.

    If you write to USARTx_DR when the shift register is empty, the data will go straight into the shift register, transmission will begin immediately and the TXE flag will will be immediately set.

Read more: http://www.micromouseonline.com/2009/12/31/stm32-usart-basics/#ixzz1pl0toOU6


Text starting at the bottom of page 606 and Fig 225 on Page 607 [!!!!!!!!] in
RM0033 Reference manual STM32F205xx, STM32F207xx, STM32F215xx and STM32F217xx advanced ARM-based 32-bit MCU seems to relate.

Related Topic