不思 发表于 2016-5-14 17:41:09

请问 stm32f103 外部晶体 何时工作?

没有下载程序的stm32f103最小系统上电,晶体上没测到波形,二脚都是低电平,是否正常?
谢谢!

不思 发表于 2016-5-14 17:43:53

中文手册第57页:
HSE晶体可以通过设置时钟控制寄存器里RCC_CR中的HSEON位被启动和关闭。

五哥1 发表于 2018-5-27 23:54:57

你要 在主程序里设置呀,不然程序不知道你要用外置还是内置的

andeyqi 发表于 2018-5-28 15:59:37

刚启动的时候是使用内部的HSI,内部HSI稳定后如果设置使用HSE则待HSE稳定后切换至HSE时钟,你的代码有可能未使用外部时钟,所以没有波

stm1024 发表于 2018-5-28 17:24:00

本帖最后由 stm1024 于 2018-5-28 17:25 编辑

首先,你要选择HSE……
建议你先看看版本为3.5的标准库,system_stm32f10x.c这个文件,最开始的描述是这样的:/*
* 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
*                      factors, AHB/APBx prescalers and Flash settings).
*                      This function is called at startup just after reset and
*                      before branch to main program. This call is made inside
*                      the "startup_stm32f10x_xx.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) is used as system clock source.
*    Then SystemInit() function is called, in "startup_stm32f10x_xx.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 8 MHz (or 25 MHz, depedning on
*    the product used), refer to "HSE_VALUE" define in "stm32f10x.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.
*/      以前我们在3.5之前的标准库里面,总要在main中调用一下SystemInit(),但是在3.5中,此项工作在启动代码中执行。
文件“startup_stm32f10x_xx.s“中的SystemInit()函数在所有设备会在进入main之前配置系统时钟,如果配置失败,HSI还是作为系统时钟源。
检查一下你的代码,是否有这个过程,如果有的话,最好调试一下看看代码挂在哪里了。

电子星辰 发表于 2018-5-29 09:53:12

不管寄存器,标准库还是HAL库,我们要使用外部高速时钟都是需要在程序里设置代码的。没有程序的stm32f103应该是默认就没有使用外部晶振的,所以晶体本来就没工作。
页: [1]
查看完整版本: 请问 stm32f103 外部晶体 何时工作?