cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX timing

e d
Associate II
Posted on June 07, 2017 at 20:18

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

0690X00000607G5QAI.png

Note: this post was migrated and contained many threaded conversations, some content may be missing.
20 REPLIES 20
Guru Vel
Associate
Posted on August 01, 2017 at 09:46

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.