2019-07-16 08:24发布
设置107系统时钟到56M.txt 下载积分: 积分 -1 分
2.61 KB, 下载次数: 42, 下载积分: 积分 -1 分
这个是官方的资料
设置107的系统时钟到72M.txt 下载积分: 积分 -1 分
2.61 KB, 下载次数: 153, 下载积分: 积分 -1 分
最多设置5个标签!
/** 00574 * @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2 00575 * and PCLK1 prescalers. 00576 * @param None 00577 * @retval None 00578 */ 00579 void SetSysClockTo72(void) 00580 { 00581 /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ 00582 /* RCC system reset(for debug purpose) */ 00583 RCC_DeInit(); 00584 00585 /* Enable HSE */ 00586 RCC_HSEConfig(RCC_HSE_ON); 00587 00588 /* Wait till HSE is ready */ 00589 HSEStartUpStatus = RCC_WaitForHSEStartUp(); 00590 00591 if (HSEStartUpStatus == SUCCESS) 00592 { 00593 /* Enable Prefetch Buffer */ 00594 FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); 00595 00596 /* Flash 2 wait state */ 00597 FLASH_SetLatency(FLASH_Latency_2); 00598 00599 /* HCLK = SYSCLK */ 00600 RCC_HCLKConfig(RCC_SYSCLK_Div1); 00601 00602 /* PCLK2 = HCLK */ 00603 RCC_PCLK2Config(RCC_HCLK_Div1); 00604 00605 /* PCLK1 = HCLK/2 */ 00606 RCC_PCLK1Config(RCC_HCLK_Div2); 00607 00608 #ifdef STM32F10X_CL 00609 /* Configure PLLs *********************************************************/ 00610 /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ 00611 RCC_PREDIV2Config(RCC_PREDIV2_Div5); 00612 RCC_PLL2Config(RCC_PLL2Mul_8); 00613 00614 /* Enable PLL2 */ 00615 RCC_PLL2Cmd(ENABLE); 00616 00617 /* Wait till PLL2 is ready */ 00618 while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) 00619 {} 00620 00621 /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */ 00622 RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5); 00623 RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9); 00624 #else 00625 /* PLLCLK = 8MHz * 9 = 72 MHz */ 00626 RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); 00627 #endif 00628 00629 /* Enable PLL */ 00630 RCC_PLLCmd(ENABLE); 00631 00632 /* Wait till PLL is ready */ 00633 while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) 00634 { 00635 } 00636 00637 /* Select PLL as system clock source */ 00638 RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); 00639 00640 /* Wait till PLL is used as system clock source */ 00641 while(RCC_GetSYSCLKSource() != 0x08) 00642 { 00643 } 00644 } 00645 else 00646 { /* If HSE fails to start-up, the application will have wrong clock configuration. 00647 User can add here some code to deal with this error */ 00648 00649 /* Go to infinite loop */ 00650 while (1) 00651 { 00652 } 00653 } 00654 }
这个是设置到72M的例子
设置107系统时钟到56M.txt 下载积分: 积分 -1 分
2.61 KB, 下载次数: 42, 下载积分: 积分 -1 分
这个是官方的资料
设置107的系统时钟到72M.txt 下载积分: 积分 -1 分
2.61 KB, 下载次数: 153, 下载积分: 积分 -1 分
这个是官方的资料
* and PCLK1 prescalers.
* @param None
* @retval None
*/
void SetSysClockTo72(void)
{
/* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if (HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
#ifdef STM32F10X_CL
/* Configure PLLs *********************************************************/
/* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
RCC_PREDIV2Config(RCC_PREDIV2_Div5);
RCC_PLL2Config(RCC_PLL2Mul_8);
/* Enable PLL2 */
RCC_PLL2Cmd(ENABLE);
/* Wait till PLL2 is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET)
{}
/* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */
RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5);
RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9);
#else
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
#endif
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{ }
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while(RCC_GetSYSCLKSource() != 0x08)
{ }
}
else
{ /* If HSE fails to start-up, the application will have wrong clock configuration. User can add here some code to deal with this error */
/* Go to infinite loop */
while (1)
{ }
}
}
这个是官方其中的一个例子,修改一下就可以用了
一周热门 更多>