2021-10-28 08:24 PM
CubeMX allows one to enter clock frequencies and have all the registers to be set back calculated. Great! This saves much fiddling. However... is there anyway for the code to determine, for example, what the frequency if a clock going to the ADC is without doing all those calculations that CubeMX saved us from?
Solved! Go to Solution.
2021-10-28 08:29 PM
There are functions like HAL_RCC_GetPCLK1Freq that you can call to calculate them. There are no hardcoded #defined values.
Per CMSIS standard, the SystemCoreClock variable reflects the current system core clock frequency and is updated when the clock changes.
2021-10-28 08:29 PM
There are functions like HAL_RCC_GetPCLK1Freq that you can call to calculate them. There are no hardcoded #defined values.
Per CMSIS standard, the SystemCoreClock variable reflects the current system core clock frequency and is updated when the clock changes.
2021-10-31 03:09 PM
Thanks! I found HAL_RCCEx_GetPLL2ClockFreq(); Which gives me the ADC input freq. Very useful.
Do you know of a function that will calculate ADC sample rate? It would need to wrap up, conversion time, oversampling , hold time, prescaler etc.
2021-10-31 03:15 PM