• while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET){}卡死


    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET){}卡死

    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) != SET){}卡死

    //

    RCC_PLLCmd(ENABLE);
    RCC_PLLConfig(RCC_PLLSource_PREDIV1,RCC_CFGR_PLLMULL6);
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET){}

    如上,问题出在哪里呢?

    问题出在PLL使能先后问题。

    注意,PLL参数配置时,只能是disable状态,否则无效。所以,应该先配置,再使能,代码如下


    RCC_PLLConfig(RCC_PLLSource_PREDIV1,RCC_CFGR_PLLMULL6);
    RCC_PLLCmd(ENABLE);
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET){}

    下面是标准库的源代码,请看第二行的注释:This function must be used only when the PLL is disabled.

    1. /**
    2. * @brief Configures the PLL clock source and multiplication factor.
    3. * @note This function must be used only when the PLL is disabled.
    4. *
    5. * @param RCC_PLLSource: specifies the PLL entry clock source.
    6. * This parameter can be one of the following values:
    7. * @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock selected as PLL clock source
    8. * @arg RCC_PLLSource_PREDIV1: PREDIV1 clock selected as PLL clock entry
    9. * @note The minimum input clock frequency for PLL is 2 MHz (when using HSE as
    10. * PLL source).
    11. *
    12. * @param RCC_PLLMul: specifies the PLL multiplication factor, which drive the PLLVCO clock
    13. * This parameter can be RCC_PLLMul_x where x:[2,16]
    14. *
    15. * @retval None
    16. */
    17. void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul)
    18. {
    19. /* Check the parameters */
    20. assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
    21. assert_param(IS_RCC_PLL_MUL(RCC_PLLMul));
    22. /* Clear PLL Source [16] and Multiplier [21:18] bits */
    23. RCC->CFGR &= ~(RCC_CFGR_PLLMULL | RCC_CFGR_PLLSRC);
    24. /* Set the PLL Source and Multiplier */
    25. RCC->CFGR |= (uint32_t)(RCC_PLLSource | RCC_PLLMul);
    26. }
    27. /**
    28. * @brief Enables or disables the PLL.
    29. * @note After enabling the PLL, the application software should wait on
    30. * PLLRDY flag to be set indicating that PLL clock is stable and can
    31. * be used as system clock source.
    32. * @note The PLL can not be disabled if it is used as system clock source
    33. * @note The PLL is disabled by hardware when entering STOP and STANDBY modes.
    34. * @param NewState: new state of the PLL.
    35. * This parameter can be: ENABLE or DISABLE.
    36. * @retval None
    37. */
    38. void RCC_PLLCmd(FunctionalState NewState)
    39. {
    40. /* Check the parameters */
    41. assert_param(IS_FUNCTIONAL_STATE(NewState));
    42. if (NewState != DISABLE)
    43. {
    44. RCC->CR |= RCC_CR_PLLON;
    45. }
    46. else
    47. {
    48. RCC->CR &= ~RCC_CR_PLLON;
    49. }
    50. }

  • 相关阅读:
    【Vue】二:Vue核心处理---模板语法
    java毕业设计冰球馆管理系统mybatis+源码+调试部署+系统+数据库+lw
    1767. 寻找没有被执行的任务对(当时对递归不熟)(NO)
    【长难句分析精讲】并列结构练习题
    debug - 用Procmon记录目标程序启动后的操作
    在Qt创建的UI中放一个显示点云的窗口(PCL+QT5)
    LabVIEW Modbus通讯稳定性提升
    领英-如何合并或注销重复领英帐号及利用领英高效开发客户技巧
    springboot2.7.10升级到3.0.8版本
    BUUCTF [BJDCTF2020]一叶障目 1
  • 原文地址:https://blog.csdn.net/mrlixirong/article/details/126293097