Question
USART2 baud rate coming out 1.5x slower than setting on STM32F4
Posted on August 16, 2014 at 04:30
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: 8PLL_Q: 7PLL_N: 336PLL_P: 2These 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!