汇集网友智慧,解决技术难题
单片机 3g gd32e23 时钟 demo keil
赞0
评论
2022-02-07
2022-02-06
点击图片添加到编辑器内容中
点击文件名将附件添加到文章中
提交
tyw
315个答案
天意无罪
284个答案
xch
206个答案
jjjyufan
197个答案
coody
185个答案
LcwSwust
142个答案
chunyang
135个答案
tpgf
110个答案
赞0
评论
2022-02-07
赞0
评论
2022-02-07
赞0
static void system_clock_8m_hxtal(void)
{
uint32_t timeout = 0U;
uint32_t stab_flag = 0U;
/* enable HXTAL */
RCU_CTL0 |= RCU_CTL0_HXTALEN;
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
do{
timeout++;
stab_flag = (RCU_CTL0 & RCU_CTL0_HXTALSTB);
}
while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
/* if fail */
if(0U == (RCU_CTL0 & RCU_CTL0_HXTALSTB)){
while(1){
}
}
/* HXTAL is stable */
/* AHB = SYSCLK */
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
/* APB2 = AHB */
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
/* APB1 = AHB */
RCU_CFG0 |= RCU_APB1_CKAHB_DIV1;
/* select HXTAL as system clock */
RCU_CFG0 &= ~RCU_CFG0_SCS;
RCU_CFG0 |= RCU_CKSYSSRC_HXTAL;
/* wait until HXTAL is selected as system clock */
while(0U == (RCU_CFG0 & RCU_SCSS_HXTAL)){
}
}
评论
2022-02-06
您需要登录后才可以回复 登录 | 注册