How to read clock frequencies from code? Even a #define for the hardcoded startup values would be useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-28 8: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.
- Labels:
-
ADC
-
RCC
-
STM32CubeMX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-28 8: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-28 8: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-31 3: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-31 3:15 PM
