2017-06-07 11:18 AM
Hi guys,
I am running into some timing issue using CubeMX, probably after upgrading to the latest version. A couple of weeks ago I noticed my SysTick running roughly twice as fast as expected (half of 1ms) so I changed my 1ms systick to Timer2 which worked fine. Today I turned on my USART3 for the first time at 9600 BAUD and could not get the HyperTerm to receive correctly (all garbage). Then I took a closer look at the signal through the scope and noticed the BAUD was actually at about 23KBAUD, which was weird because I set it in the code as:
huart3.Init.BaudRate = 9600;
After mucking around I got the HyperTerm to work normally by changing the BAUD setting to:
huart3.Init.BaudRate = 4000; // This is actually 9600 BAUD (verified with scope)
I have a hunch the BAUD rate issue is related to the SysTick issue.Anyone has this issue or is familiar with CubeMX to give me a clue here?
Thanks,
ED
Note: this post was migrated and contained many threaded conversations, some content may be missing.Solved! Go to Solution.
2017-08-01 12:46 AM
Short answer: Make sure the USE_HAL_DRIVER is defined as part of your build system (CFLAGS += -DUSE_HAL_DRIVER).
Detailed Answer: When you generate the code using CubeMx the HSE_VALUE goes into the file stm32l4xx_hal_conf.h under STM32CubMX_generated_files/Inc/
stm32l4xx_hal_conf.h
file. This file should be included in all HAL_DRIVER based project and will be included by the stm32l4xx.h (
stm32l4xx.h ->
stm32l4xx_hal.h -> stm32l4xx_hal_conf.h) only when the USE_HAL_DRIVER is defined.