I believe that, as a beginner of stm32, everyone is learning by downloading routines from the official website. Now firmwave's latest version is 1.1.0, for http://www.st.com/stonline/stappl/resourceSelector/app? Page = resourceselector & doctype = firmware & subclassid = 1521
In this routine, the 8 m external crystal oscillator is used by default. Now there is a problem. If the external crystal oscillator is not 8 m, but another example is 16 m, where should we modify it to makeProgramRunning properly.
The following example shows how to change 8 m to 16 m.
One of the changes: Hse_value in stm32f4xx_conf.h. The system uses an external 8 m crystal oscillator by default, so # define hse_value (uint32_t) 8000000) is changed to # define hse_value (uint32_t) 16000000)
Second modified: The system uses the PLL to multiply to 168 MB. Therefore, you need to modify the PLL configuration. In system_stm32f4xx.c, the default configuration is as follows:
/* Pll_vco = (hse_value or hsi_value/pll_m) * pll_n */# define pll_m 8 # define pll_n 336/* sysclk = pll_vco/pll_p */# define pll_p 2/* usb otg fs, sdio and RNG clock = pll_vco/plscsi */# define pll_q 7
You need to change pll_m to 16, otherwise it will exceed the 336m clock speed, so that the stm32 cannot work normally, the common manifestation is to fall into hardfault_handler.