|
| 1 | +From 10ac121c7e63d7abb856ec795b124dedf8dd9f49 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Martino Facchin <m.facchin@arduino.cc> |
| 3 | +Date: Thu, 2 Nov 2023 13:49:35 +0100 |
| 4 | +Subject: [PATCH] stm32h7: adc: use CLKP as clock source |
| 5 | + |
| 6 | +Fixes analogRead() interferring with DSI/SDRAM |
| 7 | +--- |
| 8 | + .../TARGET_STM32H7/analogin_device.c | 25 +------------------ |
| 9 | + 1 file changed, 1 insertion(+), 24 deletions(-) |
| 10 | + |
| 11 | +diff --git a/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c b/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c |
| 12 | +index be16b16cda..8b617e307a 100644 |
| 13 | +--- a/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c |
| 14 | ++++ b/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c |
| 15 | +@@ -36,30 +36,7 @@ void analogin_pll_configuration(void) |
| 16 | + |
| 17 | + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; |
| 18 | + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC; |
| 19 | +- if(__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI) { |
| 20 | +- PeriphClkInitStruct.PLL2.PLL2M = 16; |
| 21 | +- PeriphClkInitStruct.PLL2.PLL2N = 120; |
| 22 | +- } else { |
| 23 | +- #if HSE_VALUE==8000000 |
| 24 | +- PeriphClkInitStruct.PLL2.PLL2M = 2; |
| 25 | +- PeriphClkInitStruct.PLL2.PLL2N = 120; |
| 26 | +- #elif HSE_VALUE==16000000 |
| 27 | +- PeriphClkInitStruct.PLL2.PLL2M = 2; |
| 28 | +- PeriphClkInitStruct.PLL2.PLL2N = 60; |
| 29 | +- #elif HSE_VALUE==25000000 |
| 30 | +- PeriphClkInitStruct.PLL2.PLL2M = 5; |
| 31 | +- PeriphClkInitStruct.PLL2.PLL2N = 96; |
| 32 | +- #else |
| 33 | +- error("HSE not configured properly"); |
| 34 | +- #endif |
| 35 | +- } |
| 36 | +- PeriphClkInitStruct.PLL2.PLL2P = 3; |
| 37 | +- PeriphClkInitStruct.PLL2.PLL2Q = 4; |
| 38 | +- PeriphClkInitStruct.PLL2.PLL2R = 2; |
| 39 | +- PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_1; |
| 40 | +- PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE; |
| 41 | +- PeriphClkInitStruct.PLL2.PLL2FRACN = 0; |
| 42 | +- PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; |
| 43 | ++ PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_CLKP; |
| 44 | + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { |
| 45 | + error("analogin_init HAL_RCCEx_PeriphCLKConfig"); |
| 46 | + } |
| 47 | +-- |
| 48 | +2.42.0 |
| 49 | + |
0 commit comments