AnsweredAssumed Answered

USART2 baud rate coming out 1.5x slower than setting on STM32F4

Question asked by anteau.logan on Aug 16, 2014
Latest reply on Aug 17, 2014 by Clive One
I'm trying to simply send a character over and over to my computer using a USB to TTL adapter and USART2 on the STM32F4 discovery board. I have USART2 configured for 9600 baud which would give 104us bit pulses.

After getting junk characters on the computer, I looked at the TX signal on my scope and saw the bit widths were about 160us, or a baud rate of ~6250 bps. In my program if I set the baud rate to 9600*1.5 I actually get 9600 baud.

All of my reading seems to suggest this is an issue with a clock setting somewhere. Most commonly I see people having an incorrect value of HSE_VALUE. My HSE_VALUE is indeed set to 8000000 for the 8MHz crystal. I also even added -DHSE_VALUE=8000000 into my CFLAGS. Here are some of my other clock settings from system_stm32f4xx.c:

PLL_M: 8
PLL_Q: 7
PLL_N: 336
PLL_P: 2

These all seemed correct to me, but I could be missing something. I'm really at a loss here for what's going on. I'm hoping someone can figure it out. Let me know if you need any additional information. Thanks!


Outcomes