File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
targets/TARGET_STM/TARGET_STM32L4 Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -83,12 +83,23 @@ void analogin_init(analogin_t *obj, PinName pin)
83
83
obj -> handle .Init .Overrun = ADC_OVR_DATA_OVERWRITTEN ; // DR register is overwritten with the last conversion result in case of overrun
84
84
obj -> handle .Init .OversamplingMode = DISABLE ; // No oversampling
85
85
86
+ #if defined(TARGET_DISCO_L496AG )
87
+ /* VREF+ is not connected to VDDA by default */
88
+ /* Use 2.5V as reference (instead of 3.3V) for internal channels calculation */
89
+ __HAL_RCC_SYSCFG_CLK_ENABLE ();
90
+ HAL_SYSCFG_VREFBUF_VoltageScalingConfig (SYSCFG_VREFBUF_VOLTAGE_SCALE1 ); /* VREF_OUT2 = 2.5 V */
91
+ HAL_SYSCFG_VREFBUF_HighImpedanceConfig (SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE );
92
+ if (HAL_SYSCFG_EnableVREFBUF () != HAL_OK ) {
93
+ error ("HAL_SYSCFG_EnableVREFBUF issue\n" );
94
+ }
95
+ #endif /* TARGET_DISCO_L496AG */
96
+
86
97
// Enable ADC clock
87
98
__HAL_RCC_ADC_CLK_ENABLE ();
88
99
__HAL_RCC_ADC_CONFIG (RCC_ADCCLKSOURCE_SYSCLK );
89
100
90
101
if (HAL_ADC_Init (& obj -> handle ) != HAL_OK ) {
91
- error ("Cannot initialize ADC" );
102
+ error ("Cannot initialize ADC\n " );
92
103
}
93
104
94
105
// ADC calibration is done only once
You can’t perform that action at this time.
0 commit comments