STM32H7: FDCAN: use PLL1Q frequency for calculations

pull/14029/head
Martino Facchin 2020-12-03 10:15:15 +01:00
parent 86ee3003e7
commit 04ac8a08b3
1 changed files with 7 additions and 4 deletions

View File

@ -132,8 +132,10 @@ static void _can_init_freq_direct(can_t *obj, const can_pinmap_t *pinmap, int hz
int ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN) / hz;
#else
// STM32H7 doesn't support yet HAL_RCCEx_GetPeriphCLKFreq for FDCAN
// Internal ST ticket 92465
int ntq = 10000000 / hz;
// We use PLL1.Q clock right now so get its frequency
PLL1_ClocksTypeDef pll1_clocks;
HAL_RCCEx_GetPLL1ClockFreq(&pll1_clocks);
int ntq = pll1_clocks.PLL1_Q_Frequency / hz;
#endif
int nominalPrescaler = 1;
@ -287,8 +289,9 @@ int can_frequency(can_t *obj, int f)
int ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN) / f;
#else
// STM32H7 doesn't support yet HAL_RCCEx_GetPeriphCLKFreq for FDCAN
// Internal ST ticket 92465
int ntq = 10000000 / f;
PLL1_ClocksTypeDef pll1_clocks;
HAL_RCCEx_GetPLL1ClockFreq(&pll1_clocks);
int ntq = pll1_clocks.PLL1_Q_Frequency / f;
#endif
int nominalPrescaler = 1;