2020-06-19 11:30 PM
2020-06-20 10:33 AM
Domain 2 has 2 different peripheral clock prescalers, D2PPRE1 (for APB1) and D2PPRE2 (for APB2). You can use HAL_RCC_GetPCLK1Freq and HAL_RCC_GetPCLK2Freq to get these. These are both domain 2 clocks.
I think they chose the naming scheme based on previous chip series where the clock scheme was not so complex. One could make a case for calling them HAL_RCCEx_GetD2PCLK1Freq/HAL_RCCEx_GetD2PCLK2Freq here, but it is what it is.
The "Clock Configuration" screen in CubeMX really helps me understand the clock scheme on the H7. Might help.
2020-06-20 10:33 AM
Domain 2 has 2 different peripheral clock prescalers, D2PPRE1 (for APB1) and D2PPRE2 (for APB2). You can use HAL_RCC_GetPCLK1Freq and HAL_RCC_GetPCLK2Freq to get these. These are both domain 2 clocks.
I think they chose the naming scheme based on previous chip series where the clock scheme was not so complex. One could make a case for calling them HAL_RCCEx_GetD2PCLK1Freq/HAL_RCCEx_GetD2PCLK2Freq here, but it is what it is.
The "Clock Configuration" screen in CubeMX really helps me understand the clock scheme on the H7. Might help.
2020-06-20 11:16 AM
Thanks for the info! I've been working with the H7 for a while now, but the complexity of the clock tree still gets me sometimes! I was looking at it in CubeMX and found the 2 Prescalers (I'm looking for the I2C123 clock source in this case), but didn't notice the GetPCLKnFreq functions.
2020-06-20 11:49 AM
If HAL would be high-level library, then there would be...
uint32_t HAL_RCC_GetPeriphBusFreq(const void *pAddr);
...which knows peripheral address ranges for a specific MCU and returns it's respective bus frequency. The code is trivial and takes only few lines, but hey - to come up with this, ST would have to hire developers with a brain!
2021-12-02 03:17 AM
You are not blind. The closest thing you can get is HAL_RCCEx_GetPeriphCLKFreq which is mostly bad implemented, but continues to improve for newer controllers. Here is an example of a good implementation for the STM32G4: https://github.com/STMicroelectronics/STM32CubeG4/blob/master/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c#L650
Would be really nice if this level of detail is implemented for other controllers as well. Same holds for a high level API providing the clock speed of a certain timer instance which is a little rocket science to figure out (Different Peripheral Clocks for different timers, Timer Prescaler, TIMPRE, HCLK).