完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
后来去看了,ST官方的资料,其实那本参考手册上有两个例的,现在放在这里,大家一起学习
/** 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的例子 |
|
|
|
/** * @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2
* 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) { } } } 这个是官方其中的一个例子,修改一下就可以用了 |
|
|
|
很遗憾,在调用库的情况下,这个函数在编译时提出:
..USERsrcmain.c(174): error: #20: identifier "RCC_PLLSource_PREDIV1" is undefined ..USERsrcmain.c: RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9); 请高手支招啊 |
|
|
|
不好意思,之前修改了库里的内容,所以才会导致出错的
|
|
|
|
请问下A口怎么配置的,我知道TRISA和portA,但是最后四位输出错误,都为0 求解
|
|
|
|
楼主您好!请问107需要改哪些部分,我做的时钟秒不走,比如只显示20:10:10,您上面的问题现在也遇到,请问需要修改那那一部分?谢谢您
|
|
|
|
感觉时钟真的很难理解!
|
|
|
|
{:1:}{:1:}{:1:}{:1:}{:1:}
|
|
|
|
{:12:}
|
|
|
|
走这个路线就行
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
飞凌嵌入式ElfBoard ELF 1板卡-CAN编程示例之开发板测试
654 浏览 0 评论
该问题是用APP给芯海科技的CST92F25芯片发指令是出现的
2242 浏览 1 评论
771 浏览 0 评论
1530 浏览 1 评论
2276 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 03:13 , Processed in 1.398722 second(s), Total 96, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号