2011-11-19 07:18 AM
Hi Everbody!
I'm trying to set up an USART Connection to my Notebook. Everything works fine but does anyone have a clue why I have to multiply the baudrate-setting with 3 to get the correct baudrate? for Example: USART_InitStructure.USART_BaudRate = 9600*3; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx;Attached you can also find the full configuration.Thanks a lot!Franz2011-11-19 11:37 AM
Well the clocks are not what you think they are, either HSI/HSE are different (physical vs defined) or the clock setting are getting fouled up.
The code makes a lot of assumptions about the initial content of RCC->CFGR. Have the part output the clocks via MCO, and check they are what you expect. One might guess the project thinks HSE_VALUE is 24 or 25 MHz, not the 8 MHz on the STM32F4 Discovery board.2011-11-20 03:22 AM
You were right!
the Problem were these lines of code in stm32f4xx.h: #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */I just redefined it in stm32f4xx_conf.h and now it works perfectly fine!Thank you!2011-11-20 08:06 AM
With Keil/IAR projects this is often stored as a compiler command line option, as a define ''-DHSE_VALUE=8000000''. If you use an existing project/template this is hidden in the metadata, and easily missed if you create a project from scratch.