cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f446 Enabling USART send unwanted byte

Paul Florence
Associate II
Posted on July 10, 2018 at 22:37

Hi,

When I enable my USART peripheral it sends an unwanted byte interpreted as 0xFE.

To enable the USART peripheral, I first enable it in the APBENR register then I reset it through APBRSTR.

I then disable flow control, and program the baudrate.

I then configure the number of stop bits (0, this is quasi default communication) and then I enable USART through CR1 register. After that all what is left is to enable the TE and RE bit in CR1.

After sending this unwanted byte, it all works very well because I can send data without any problem at the correct baudrate. There is juste this annoying byte that get sent first...

Do you have any idea where I should look ?

I think it may be related to this note in the datasheet :

Note: 1: During transmission, a “0�? pulse on the TE bit (“0�? followed by “1�?) sends a preamble

(idle line) after the current word, except in smartcard mode.

2: When TE is set there is a 1 bit-time delay before the transmission starts.

Thanks a lot & have a nice day !

Note: this post was migrated and contained many threaded conversations, some content may be missing.
14 REPLIES 14
Posted on July 11, 2018 at 14:16

Not that I know of.

Except enabling the clock for the appropriate GPIO port.

Posted on July 11, 2018 at 15:09

I am currently implementing an

https://en.wikipedia.org/wiki/Hardware_abstraction

for the micro-controller, and the language is not C so I don't think showing code would be really useful.
Posted on July 11, 2018 at 15:12

I think I have a problem with my GPIO configuration because by default when I enable them there is the same signal that appears on the logical analyzer...

My routine for the GPIO is :

  1. Enable the gpio in AHB1 (i use GPIOC)
  2. Set the output to push-pull in OTYPER
  3. Set the output to pull_up in PUPDR
  4. Write the AF mode in MODER then in AFR

turboscrew
Senior III
Posted on July 12, 2018 at 06:50

I set up the USART first and turn the TX pin as output later. The USART ticks out the byte, but it's not getting out of the chip. And that's why I also use TXEIE to start/stop transmission, not TCIE.

Dan Mackie
Senior
Posted on July 12, 2018 at 14:31

I agree with Juha.  For standard serial I/O, I would try only enabling the transmitter as part of the output service routine, and disable it when no data was ready to go.  When I had data ready to transmit, and in the transmit output register, then I would enable the transmitter (really enable the transmit register empty interrupt).