2019-08-21 12:53 PM
When using an external crystal in the MXcube for the STM32G474 mcu.
conditions:
Change High Speed Clock (HSE) to Crystal/Ceramic Resonator in the pinout & Configuration tab page
Change the input frequency to 16Mhz in the Clock configuration tab page
After generation the code, op the file 'system_stm32G4xx.c file.
The HSE_VALUE isn't changed to 16000000U
#define HSE_VALUE 8000000U
2019-08-24 03:35 PM
I found there was no clock initialization at all. You have to patch registers directly or use low level interface.
2019-08-24 09:45 PM
Guys, learn basic programming first...
#if !defined (HSE_VALUE)
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
/* ########################## Oscillator Values adaptation ####################*/
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
You (or CubeMX) have to adjust HSE_VALUE in file stm32g4xx_hal_conf.h or set it in a global project settings and that value will override predefined 8000000UL.