AnsweredAssumed Answered

STM32F407: USART Baudrate wrong by factor 3

Question asked by winkler.tom on Aug 8, 2012
Latest reply on Mar 28, 2014 by Clive One

I'm in the process of evaluation the STM32F407 for a larger project we are currently working on.
For my evaluations I'm using an Olimex P407 board (link see below). So far I manged to flash the board (using the ST-Link programmer of an STM32F4 discovery) flash some LEDs etc. Next thing on my list is getting the UARTS working to print some messages. I successfully programmed the USARTs (3 and 6) but on the PC side I'm only getting garbage no matter which baud rates I use. I tried 9600 up to 115200 and confirmed that both the PC and the board use the same baud rate and configuration (8N1).

I then attached a scope to the USART pins to check that is going on. I noticed that for 9600 bauds the time for a single bit is 33.4us while I expected 1/9600 = 104us. Similarly for 155200 i measured a bit time of 2.8us while I expected 8.6us. So the bit time is roughly off by a factor of 3. For testing purpose I next simply divided the baud rate in my USART setup code by 3. And suddenly I'm getting clear text on the PC side (set to 115200 and the STM32's USART6 set to 115200/3).

I could not figure out yet what I'm doing wrong. The Olimex board is using an external 25Mhz crystal for HSE which is also set in stm32f4xx.h. I also re-generated the system_stm32f4xx.h using the STM Excel sheet to make sure my settings are correct. For reference purposes I uploaded these two files and my USART setup and test code to pastebin (see links below).

I'd be happy if someone could provide some ideas what I might be doing wrong.

simple USART init and test:
Olimex board:

Thank you,