stm8s 时钟库函数选择内部RC初始化

//本文选择16M内部RC震荡。分频为1 即系统时钟为16M
void CLK_HSICmd(FunctionalState NewState)
{ /* Check the parameters */
assert_param(IS_FUNCTIONALSTATE_OK(NewState)); if (NewState != DISABLE)
{
/* Set HSIEN bit */
CLK->ICKR |= CLK_ICKR_HSIEN;
}
else
{
/* Reset HSIEN bit */
CLK->ICKR &= (u8)(~CLK_ICKR_HSIEN);
} }
void CLK_HSIPrescalerConfig(CLK_Prescaler_TypeDef HSIPrescaler)
{ /* check the parameters */
assert_param(IS_CLK_HSIPRESCALER_OK(HSIPrescaler)); /* Clear High speed internal clock prescaler */
CLK->CKDIVR &= (u8)(~CLK_CKDIVR_HSIDIV); /* Set High speed internal clock prescaler */
CLK->CKDIVR |= (u8)HSIPrescaler; } void CLK_Configuration(void)
{
CLK_HSICmd(ENABLE);/* Set HSIEN bit */ CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); /* Fmaster = 16MHz */ } //初始化时,调用下面函数就可以:
CLK_Configuration();

上一篇:Keil中使用宏编译来定义DEBUG输出


下一篇:NOIP树上问题总结