你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32F4 使用HSI通过PLL提供SYSTEMCLOCK,程序跑飞

[复制链接]
vlinda5150 提问时间:2015-10-30 16:25 /
使用HSI通过PLL提供SYSTEMCLOCK,下面代码每次执行到RCC->CFGR |= RCC_CFGR_SW_PLL;  程序就执行不下去了。求各位牛人帮忙看看问题出在哪里?
void SystemInit(void)
{
   uint32_t tmp = 0;
  /* Reset the RCC clock configuration to the default reset state ------------*/
  /* Set HSION bit */
  RCC->CR |= (uint32_t)0x00000001;

  /* Reset CFGR register */
  RCC->CFGR = 0x00000000;

  /* Reset HSEON, CSSON and PLLON bits */
  RCC->CR &= (uint32_t)0xFEF6FFFF;

  /* Reset PLLCFGR register */
  RCC->PLLCFGR = 0x24003010;

  /* Reset HSEBYP bit */
  RCC->CR &= (uint32_t)0xFFFBFFFF;

  /* Disable all interrupts */
  RCC->CIR = 0x00000000;

#ifdef DATA_IN_ExtSRAM
  SystemInit_ExtMemCtl();
#endif /* DATA_IN_ExtSRAM */
//////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef PLL_SOURCE_HSI  
  /* At this stage the HSI is already enabled */

    /* Configure the main PLL */
    RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
                   (RCC_PLLCFGR_PLLSRC_HSI) | (PLL_Q << 24);

    /* HCLK = SYSCLK / 1*/
    RCC->CFGR |= RCC_CFGR_HPRE_DIV1;

    /* PCLK2 = HCLK / 2*/
    RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;

    /* PCLK1 = HCLK / 4*/
    RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;

    /* Enable the main PLL */
    RCC->CR |= RCC_CR_PLLON;

    /* Wait till the main PLL is ready */
    while((RCC->CR & RCC_CR_PLLRDY) == 0)
    {
    }

    /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
    FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
    /* Select the main PLL as system clock source */
    RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
    RCC->CFGR |= RCC_CFGR_SW_PLL;  
    tmp = (RCC->CFGR) & (uint32_t)RCC_CFGR_SWS;
    /* Wait till the main PLL is used as system clock source */
    while (tmp != RCC_CFGR_SWS_PLL)
    {
      tmp = (RCC->CFGR) & (uint32_t)RCC_CFGR_SWS;
    }
#else
  /* Configure the System clock source, PLL Multiplier and Divider factors,
     AHB/APBx prescalers and Flash settings ----------------------------------*/
  SetSysClock();
#endif /* PLL_SOURCE_HSI */
//////////////////////////////////////////////////////////////////////////////////////////////////////  
  /* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}

收藏 评论4 发布时间:2015-10-30 16:25

举报

4个回答
vlinda5150 回答时间:2015-10-30 16:54:04
已解决,字数字数字数
埃斯提爱慕 回答时间:2015-10-30 22:11:14
提示: 作者被禁止或删除 内容自动屏蔽
你好我好大家好! 回答时间:2015-10-31 09:34:27
学习学习  
mcuyangyifan 回答时间:2015-10-31 10:36:53
分享一下解决办法吧,F4的PLL时钟源能选外部时钟?
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版