Skip to content

Commit 5a1c49f

Browse files
author
Cruz Monrreal
authored
Merge pull request #8168 from jeromecoutant/PR_ADC_DISCOL496
DISCO_L496AG : enable ADC
2 parents 43cf16d + f510eff commit 5a1c49f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

targets/TARGET_STM/TARGET_STM32L4/analogin_device.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,23 @@ void analogin_init(analogin_t *obj, PinName pin)
8686
obj->handle.Init.DFSDMConfig = 0;
8787
#endif
8888

89+
#if defined(TARGET_DISCO_L496AG)
90+
/* VREF+ is not connected to VDDA by default */
91+
/* Use 2.5V as reference (instead of 3.3V) for internal channels calculation */
92+
__HAL_RCC_SYSCFG_CLK_ENABLE();
93+
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE1); /* VREF_OUT2 = 2.5 V */
94+
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
95+
if (HAL_SYSCFG_EnableVREFBUF() != HAL_OK) {
96+
error("HAL_SYSCFG_EnableVREFBUF issue\n");
97+
}
98+
#endif /* TARGET_DISCO_L496AG */
99+
89100
// Enable ADC clock
90101
__HAL_RCC_ADC_CLK_ENABLE();
91102
__HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_SYSCLK);
92103

93104
if (HAL_ADC_Init(&obj->handle) != HAL_OK) {
94-
error("Cannot initialize ADC");
105+
error("Cannot initialize ADC\n");
95106
}
96107

97108
// ADC calibration is done only once

0 commit comments

Comments
 (0)