Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stm32] RCC: Fix wrong PLL HSI source selection #414

Merged
merged 3 commits into from
Jun 8, 2020

Conversation

rleh
Copy link
Member

@rleh rleh commented Jun 8, 2020

On STM32F042 (and other STM32F0/STM32F3) Rcc::enablePll(Rcc::PllSource::InternalClock, pllFactors) selects the Hsi clock divided by 2 (and not divided by PllFactors::pllPrediv) as pll source.

enum class PllSource : uint32_t {
  /// High speed internal clock (8 MHz)
  Hsi = RCC_CFGR_PLLSRC_HSI_DIV2,
  InternalClock = Hsi,
  // [...]
}
#define RCC_CFGR_PLLSRC_HSI_DIV2 (0x00000000U) /*!< HSI clock divided by 2 selected as PLL entry clock source */

grafik


Related to #413

@rleh rleh added the fix 💎 label Jun 8, 2020
@rleh
Copy link
Member Author

rleh commented Jun 8, 2020

For more information see #413 (comment)

cc @nesos @salkinium

@rleh rleh requested a review from salkinium June 8, 2020 10:51
@rleh
Copy link
Member Author

rleh commented Jun 8, 2020

Seems like only some STM32F0 have the RCC_CFGR_PLLSRC_HSI_PREDIV option. 😒

The following devices do not have the pre-divider (according to CMSIS headers):

  • stm32f030x6
  • stm32f030x8
  • stm32f031x6
  • stm32f038xx
  • stm32f051x8
  • stm32f058xx

@rleh
Copy link
Member Author

rleh commented Jun 8, 2020

Maybe this problem is also related to #99 ?!

@rleh rleh force-pushed the fix/f0_f3_pll_hsi_prediv branch from 39409b4 to 1df8c89 Compare June 8, 2020 14:40
@rleh rleh force-pushed the fix/f0_f3_pll_hsi_prediv branch from 1df8c89 to 81acd28 Compare June 8, 2020 15:00
@rleh rleh force-pushed the fix/f0_f3_pll_hsi_prediv branch from 81acd28 to 01d439c Compare June 8, 2020 15:09
Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

InternalClock = Hsi,
%% endif
%% if (target["family"] == "f0") or (target["family"] == "f3" and target["size"] in ["8", "c"])
HsiDiv2 = RCC_CFGR_PLLSRC_HSI_DIV2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ST, whyyyyyyy?

@salkinium salkinium merged commit 91a590e into modm-io:develop Jun 8, 2020
@rleh rleh deleted the fix/f0_f3_pll_hsi_prediv branch June 8, 2020 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants