STM32 Tick Clock source problem

Source: Internet
Author: User

#if!defined (Hse_value)
#define Hse_value ((uint32_t) 24000000U)/*!< VALUE of the External oscillator in Hz */
#endif/* Hse_value */

The size of the Hse_value value determines the period in which the clock ticks. The setting of this value does not affect the clock cycle of the main frequency and the changes of the associated timer.

__weak uint32_t hal_rcc_getsysclockfreq (void)
{
uint32_t pllm = 0U, Pllvco = 0U, PLLP = 0U;
uint32_t sysclockfreq = 0U;

/* Get SYSCLK Source-------------------------------------------------------*/
Switch (RCC-&GT;CFGR & RCC_CFGR_SWS)
{
Case RCC_CFGR_SWS_HSI:/* HSI used as system clock source */
{
Sysclockfreq = Hsi_value;
Break
}
Case RCC_CFGR_SWS_HSE:/* HSE used as system clock source */
{
Sysclockfreq = Hse_value;
Break
}
Case RCC_CFGR_SWS_PLL:/* PLL used as system clock source */
{
/* Pll_vco = (hse_value or HSI_VALUE/PLLM) * Plln
SYSCLK = PLL_VCO/PLLP */
PLLM = rcc->pllcfgr & rcc_pllcfgr_pllm;
if (__hal_rcc_get_pll_oscsource ()! = RCC_PLLSOURCE_HSI)
{
/* HSE used as PLL clock source */
Pllvco = ((HSE_VALUE/PLLM) * ((RCC-&GT;PLLCFGR & Rcc_pllcfgr_plln) >> position_val (Rcc_pllcfgr_plln)));
}
Else
{
/* HSI used as PLL clock source */
Pllvco = ((HSI_VALUE/PLLM) * ((RCC-&GT;PLLCFGR & Rcc_pllcfgr_plln) >> position_val (Rcc_pllcfgr_plln)));
}
PLLP = (((((Rcc->pllcfgr & RCC_PLLCFGR_PLLP) >> position_val (RCC_PLLCFGR_PLLP)) + 1U) *2u);

Sysclockfreq = PLLVCO/PLLP;
Break
}
Default
{
Sysclockfreq = Hsi_value;
Break
}
}
return sysclockfreq;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.