Skip to content

Commit

Permalink
patches: fix stm32h7 ADC clock source
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Nov 2, 2023
1 parent 7fc89ba commit a758746
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions patches/0214-stm32h7-adc-use-CLKP-as-clock-source.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 10ac121c7e63d7abb856ec795b124dedf8dd9f49 Mon Sep 17 00:00:00 2001
From: Martino Facchin <m.facchin@arduino.cc>
Date: Thu, 2 Nov 2023 13:49:35 +0100
Subject: [PATCH] stm32h7: adc: use CLKP as clock source

Fixes analogRead() interferring with DSI/SDRAM
---
.../TARGET_STM32H7/analogin_device.c | 25 +------------------
1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c b/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c
index be16b16cda..8b617e307a 100644
--- a/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c
+++ b/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c
@@ -36,30 +36,7 @@ void analogin_pll_configuration(void)

RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC;
- if(__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI) {
- PeriphClkInitStruct.PLL2.PLL2M = 16;
- PeriphClkInitStruct.PLL2.PLL2N = 120;
- } else {
- #if HSE_VALUE==8000000
- PeriphClkInitStruct.PLL2.PLL2M = 2;
- PeriphClkInitStruct.PLL2.PLL2N = 120;
- #elif HSE_VALUE==16000000
- PeriphClkInitStruct.PLL2.PLL2M = 2;
- PeriphClkInitStruct.PLL2.PLL2N = 60;
- #elif HSE_VALUE==25000000
- PeriphClkInitStruct.PLL2.PLL2M = 5;
- PeriphClkInitStruct.PLL2.PLL2N = 96;
- #else
- error("HSE not configured properly");
- #endif
- }
- PeriphClkInitStruct.PLL2.PLL2P = 3;
- PeriphClkInitStruct.PLL2.PLL2Q = 4;
- PeriphClkInitStruct.PLL2.PLL2R = 2;
- PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_1;
- PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
- PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
- PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2;
+ PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_CLKP;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
error("analogin_init HAL_RCCEx_PeriphCLKConfig");
}
--
2.42.0

0 comments on commit a758746

Please sign in to comment.