其他分享
首页 > 其他分享> > stm8s 时钟库函数选择内部RC初始化

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();

标签:stm8s,u8,CLK,NewState,void,RC,ICKR,HSIEN,库函数
来源: https://www.cnblogs.com/ldxsuanfa/p/10728894.html