STM32 PLL Clock Frequency Calculation: HSI vs HSE
This code snippet checks the source of the input clock for the PLL (Phase Locked Loop) and calculates the frequency of the output clock.
If the PLL source is the internal HSI oscillator (pllsource == 0x00), the code divides the HSI_VALUE (internal oscillator frequency) by 2 and multiplies it by 'pllmull' (a user-specified multiplication factor) to calculate the output PLL frequency.
If the PLL source is the external HSE oscillator, the code checks if the HSE_VALUE (external oscillator frequency) is divided by 2 using the CFG_PLLHSEPRES_MASK register. If it is divided by 2, the code divides the HSE_VALUE by 2, multiplies it by 'pllmull', and calculates the output PLL frequency. If it is not divided by 2, the code directly multiplies the HSE_VALUE by 'pllmull' to calculate the output PLL frequency.
In either case, the output PLL frequency is stored in the variable 'pllclk'.
原文地址: https://www.cveoy.top/t/topic/nF6d 著作权归作者所有。请勿转载和采集!