当前位置:网站首页>Modify stm32f030 clock source to internal crystal oscillator (HEI)
Modify stm32f030 clock source to internal crystal oscillator (HEI)
2022-06-24 23:35:00 【mialo163】
modify SetSysClock() function , Change the clock source from the default HSE Change to internal HSI The clock
system_stm32f0xx.c
static void SetSysClock(void)
{
__IO uint32_t StartUpCounter = 0, HSIStatus = 0;
/* SYSCLK, HCLK, PCLK configuration ----------------------------------------*/
/* Enable HSI */
RCC->CR |= ((uint32_t)RCC_CR_HSION);//((uint32_t)RCC_CR_HSEON)
/* Wait till HSI is ready and if Time out is reached exit */
do
{
HSIStatus = RCC->CR & RCC_CR_HSIRDY;//RCC->CR & RCC_CR_HSERDY;
StartUpCounter++;
} while((HSIStatus == 0) && (StartUpCounter != HSI_STARTUP_TIMEOUT));
if ((RCC->CR & RCC_CR_HSIRDY) != RESET)//((RCC->CR & RCC_CR_HSERDY) != RESET
{
HSIStatus = (uint32_t)0x01;
}
else
{
HSIStatus = (uint32_t)0x00;
}
if (HSIStatus == (uint32_t)0x01)
{
/* Enable Prefetch Buffer and set Flash Latency */
FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
/* HCLK = SYSCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
/* PCLK = HCLK */
RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE_DIV1;
/* PLL configuration = HSE * 6 = 48 MHz */
/* PLL configuration = HSI/2 * 12 = 48 MHz */
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL));
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSI_DIV2| RCC_CFGR_PLLMULL12);
// RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLMULL6)
/* Enable PLL */
RCC->CR |= RCC_CR_PLLON;
/* Wait till PLL is ready */
while((RCC->CR & RCC_CR_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_PLL)
{
}
}
else
{ /* If HSI fails to start-up, the application will have wrong clock
configuration. User can add here some code to deal with this error */
}
}
边栏推荐
- R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用exp函数、confint函数、coef函数获取模型中每个变量(自变量改变一个单位)对应的优势比的置信区间
- 372. 棋盘覆盖
- 【UVM入门 ===> Episode_8 】~ Sequence 和 Sequencer、Sequence 层次化
- First person singular reading notes
- 一文理解OpenStack网络
- 7-2 求解买股票问题
- 7-7 solving mode problems
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用AIC函数比较两个模型的AIC值的差异(简单模型和复杂模型)
- 7-6 laying oil well pipeline
- R语言dplyr包select函数将dataframe数据中的指定数据列移动到dataframe数据列中的第一列(首列)
猜你喜欢

Ganglia 的安装与部署

Morris遍曆

Enterprise data leakage prevention solution sharing

Continuous soul torture from two MySQL indexes of interviewers
HMS core discovery Episode 13 live broadcast Preview - building the real world in mobile games

Volcano成Spark默认batch调度器

斐波那契
![[JS] - [tree] - learning notes](/img/62/de4fa2a7c5e52c461b8be4a884a395.png)
[JS] - [tree] - learning notes

Latest development of jetpack compose
![[JS] - [array, stack, queue, linked list basics] - Notes](/img/c6/a1bd3b8ef6476d7d549abcb442949a.png)
[JS] - [array, stack, queue, linked list basics] - Notes
随机推荐
Collation of Digital IC design experience (II)
R语言dplyr包group_by函数和summarise_at函数计算dataframe计算不同分组的计数个数和均值(Summarise Data by Categorical Variable)
Simple use of libnum Library (hexadecimal string conversion)
HarmonyOS访问数据库实例(3)--用ORM Bee测下HarmonyOS到底有多牛
7-7 求解众数问题
golang convert json string to map
SimpleDateFormat 格式化和解析日期的具体类
明天就是PMP考试了(6月25日),这些大家都了解了吗?
7-8 循环日程安排问题
7-3 maximum sub segment and
7-8 circular scheduling problem
Morris遍历
Chapter VI skills related to e-learning 5 (super parameter verification)
[JS] - [array, stack, queue, linked list basics] - Notes
去商场逛街
379. hide and seek
如何化解35岁危机?华为云数据库首席架构师20年技术经验分享
376. machine tasks
Ganglia 的安装与部署
7-3 最大子段和