Precautions for switching 8 M recommended by routine to custom 4-26m for stm32f407zg microcontroller Crystal Oscillator

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.