1、前面介绍了系统时钟配置工具和GPIO配置工具,在这里就可以用到了,笔者看来GPIO工具不利于初学者对STM32的认识,不建议初学者使用,笔者这里也没用用的,只是用的了时钟配置工具。下面简单介绍,系统时钟工具怎么用,其实打开就可以发现,其实excel宏加载文件,很多人不知道如何配置这个宏才能正常使用该工具,即便配置指导就在文件中,笔者初期也是搞了很久才配置好宏,后面发现有个更简单的方法,微软 office 2010.
1) 打开excel,点击另存为。
2)选择保存路径,保存类型(关键)选择为:excel 加载宏,点击"保存"。
3)接着点击原文件中的保存按钮,会弹出 ”另存为“,这里只要更改文件名(避免与原文件冲突),其他不要更改,点击"保存"。
4)打开第二次保存的文件,就会发现可以配置了。其中,RUN是配置生效,Generate是生成C文件。
2、系统时钟配置为PLL,48M,具体如下;
/**
******************************************************************************
* @file system_stm32f0xx.c
* @author MCD Application Team
* @version V1.0.1
* @date 14-July-2014
* @brief CMSIS Cortex-M0 Device Peripheral Access Layer System Source File.
* This file contains the system clock configuration for STM32F0xx devices,
* and is generated by the clock configuration tool
* STM32f0xx_Clock_Configuration_V1.0.1.xls
*
* 1. This file provides two functions and one global variable to be called from
* user application:
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
* and Divider factors, AHB/APBx prescalers and Flash settings),
* depending on the configuration made in the clock xls tool.
* This function is called at startup just after reset and
* before branch to main program. This call is made inside
* the "startup_stm32f0xx.s" file.
*
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
* by the user application to setup the SysTick
* timer or configure other parameters.
*
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
* be called whenever the core clock is changed
* during program execution.
*
* 2. After each device reset the HSI (8 MHz Range) is used as system clock source.
* Then SystemInit() function is called, in "startup_stm32f0xx.s" file, to
* configure the system clock before to branch to main program.
*
* 3. If the system clock source selected by user fails to startup, the SystemInit()
* function will do nothing and HSI still used as system clock source. User can
* add some code to deal with this issue inside the SetSysClock() function.
*
* 4. The default value of HSE crystal is set to 8MHz, refer to "HSE_VALUE" define
* in "stm32f0xx.h" file. When HSE is used as system clock source, directly or
* through PLL, and you are using different crystal you have to adapt the HSE
* value to your own configuration.
*
* 5. This file configures the system clock as follows:
*=============================================================================
*=========================&#