源文件名: ch32v20x_rcc.c
/********************************************************************* ?*?@fn??????RCC_PCLK1Config ?* ?*?@brief???Configures?the?Low?Speed?APB?clock?(PCLK1). ?* ?*?@param???RCC_HCLK?-?defines?the?APB1?clock?divider.?This?clock?is?derived?from ?*????????the?AHB?clock?(HCLK). ?*????????????RCC_HCLK_Div1?-?APB1?clock?=?HCLK. ?*????????????RCC_HCLK_Div2?-?APB1?clock?=?HCLK/2. ?*????????????RCC_HCLK_Div4?-?APB1?clock?=?HCLK/4. ?*????????????RCC_HCLK_Div8?-?APB1?clock?=?HCLK/8. ?*????????????RCC_HCLK_Div16?-?APB1?clock?=?HCLK/16. ?* ?*?@return??none ?*/ void?RCC_PCLK1Config(uint32_t?RCC_HCLK) { ??uint32_t?tmpreg?=?0; ??tmpreg?=?RCC->CFGR0; ??tmpreg?&=?CFGR0_PPRE1_Reset_Mask; ??tmpreg?|=?RCC_HCLK; ??RCC->CFGR0?=?tmpreg; } /********************************************************************* ?*?@fn??????RCC_PCLK2Config ?* ?*?@brief???Configures?the?High?Speed?APB?clock?(PCLK2). ?* ?*?@param???RCC_HCLK?-?defines?the?APB2?clock?divider.?This?clock?is?derived?from ?*????????the?AHB?clock?(HCLK). ?*????????????RCC_PCLK2_Div2?-?APB2?clock?=?HCLK. ?*????????????RCC_PCLK2_Div4?-?APB2?clock?=?HCLK/2. ?*????????????RCC_PCLK2_Div6?-?APB2?clock?=?HCLK/4. ?*????????????RCC_PCLK2_Div8?-?APB2?clock?=?HCLK/8. ?* ?*?@return??none ?*/ void?RCC_PCLK2Config(uint32_t?RCC_HCLK) { ??uint32_t?tmpreg?=?0; ??tmpreg?=?RCC->CFGR0; ??tmpreg?&=?CFGR0_PPRE2_Reset_Mask; ??tmpreg?|=?RCC_HCLK?<<?3; ??RCC->CFGR0?=?tmpreg; }
结合数据手册的说明:
RCC_PCLK2Config 函数的注释里针对RCC_HCLK的描述不正确,
这里可选的枚举值应该是同上面RCC_PCLK1Config的一样, RCC_HCLK_ 前缀的才是正确的, 但是注释写的却是RCC_PCLK2_前缀的.
热门产品 :
CH641: PD及无线充电专用MCU