-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patches: fix stm32h7 ADC clock source
Should fix arduino-libraries/Arduino_GigaDisplayTouch#2
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|