编辑: hyszqmzc 2016-12-28

} 因为默认就是工作在 HSI,所以只需要将 SetSysClock()和SystemCoreClockUpdate()两个语句删掉,就可以了.如下: // This function is called after RAM initialization and before main. void mbed_sdk_init() { /* Configure the Cube driver */ SystemCoreClock = 8000000;

// At this stage the HSI is used as system clock HAL_Init();

// reset serial next time it is called, now that system clock is set stdio_uart_inited = 0;

} 编译,测试,发现可以正常的工作,LED 为每

1 秒亮或灭,串口波特率恢复到正常的 9600. 2) 设置工作主频为 48MHz.使用 48MHz 造成的问题,主要是由于串口的初始化发生在时钟配置为 48MHz 之前,所以 最快的解决办法就是把顺序调过来.于是方法如下: 在 mbed_overrides.c 文件中,将下面这个语句删掉: /* Configure the Cube driver */ SystemCoreClock = 8000000;

// At this stage the HSI is used as system clock 把SetSysClock()和SystemCoreClockUpdate()两个时钟语句剪切下来: /* Configure the System clock source, PLL Multiplier and Divider factors, AHB/APBx prescalers and Flash settings */ SetSysClock();

// Update the SystemCoreClock variable. SystemCoreClockUpdate();

将这两个语句粘贴到 system_stm32f0xx.c 中void SystemInit(void)函数中的最后,这样就可以达到一复位就首先 初始化时钟的效果. 编译,测试,一样也工作正常了. 同样的道理,回头到 mbed 开发平台中,将相应的文件进行修改,也就可以正常工作了.其中, mbed_overrides.c 文件的位置位于: mbed_src/targets/hal/TARGET_STM/TARGET_STM32F0/ system_stm32f0xx.c 文件的位置位于: mbed_sr........

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题