当前位置:网站首页>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 */
}
}
边栏推荐
- [basic knowledge] ~ half adder & full adder
- R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用exp函数、confint函数、coef函数获取模型中每个变量(自变量改变一个单位)对应的优势比的置信区间
- OpenSSL SSL_read: Connection was reset, errno 10054
- 7-8 ladder cloud vertical
- Helix distance of point
- throttle-debounce.js:一个小型的防抖节流函数库
- 376. 機器任務
- [JS] - [array, Stack, queue, Link List basis] - Notes
- Installation and deployment of ganglia
- golang convert json string to map
猜你喜欢
What you must know about time series database!

7-7 digital triangle

Morris遍曆

go 语言指针,值引用和指针引用
![[JS] - [tree] - learning notes](/img/62/de4fa2a7c5e52c461b8be4a884a395.png)
[JS] - [tree] - learning notes

点的螺旋距离

Actipro WPF Controls 2022.1.2

Volcano成Spark默认batch调度器

Mousse shares listed on Shenzhen Stock Exchange: becoming popular by mattress and "foreign old man", with a market value of 22.4 billion yuan

Actipro WPF Controls 2022.1.2
随机推荐
RT thread uses RT kprintf
libnum库简单使用(进制字符串转换)
R语言dplyr包group_by函数和summarise_at函数计算dataframe计算不同分组的计数个数和均值(Summarise Data by Categorical Variable)
Yyds dry goods counting uses xshell to implement agent function
golang convert map to json string
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、对匹配后的样本的不同分组对应的目标变量的均值进行Welch双样本t检验分析、双独立样本t检验
2021-2022中国金融数字化“新”洞察行业研究报告
UNION ALL UNION FULL JOIN
Morris traverse
376. Tâches mécaniques
R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses exp function, confint function and coef function to obtain the confidence
7-6 铺设油井管道
Inventory of data governance status of six major banks: governance architecture, data standards and data middle office (April 2022)
Yyds dry goods inventory tells us 16 common usage scenarios of redis at one go
Collation of Digital IC design experience (II)
年薪百万,7年测试经验:守在一个还算不错的赛道,慢慢积累,等风来
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses exp function and coef function to obtain the corresponding odds rat
一文理解OpenStack网络
throttle-debounce. JS: a small anti shake throttling function library
Unveiling the secrets of the Winter Olympics | smartbi's partners supported the "front and back" of the Beijing Winter Olympics