File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8 Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,16 @@ void analogin_init(analogin_t *obj, PinName pin) {
73
73
if (adc_inited == 0 ) {
74
74
adc_inited = 1 ;
75
75
76
+ AdcHandle .Instance = (ADC_TypeDef * )(obj -> adc );
77
+
76
78
// Enable ADC clock
77
79
__ADC1_CLK_ENABLE ();
78
80
79
81
// Configure ADC
80
82
AdcHandle .Init .OversamplingMode = DISABLE ;
81
83
AdcHandle .Init .ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2 ; // ADCCLK = 8 MHz (HSI 16 MHz / 2)
82
84
AdcHandle .Init .Resolution = ADC_RESOLUTION12b ;
83
- AdcHandle .Init .SamplingTime = ADC_SAMPLETIME_1CYCLE_5 ;
85
+ AdcHandle .Init .SamplingTime = ADC_SAMPLETIME_7CYCLES_5 ;
84
86
AdcHandle .Init .ScanDirection = ADC_SCAN_DIRECTION_UPWARD ;
85
87
AdcHandle .Init .DataAlign = ADC_DATAALIGN_RIGHT ;
86
88
AdcHandle .Init .ContinuousConvMode = DISABLE ;
@@ -92,8 +94,13 @@ void analogin_init(analogin_t *obj, PinName pin) {
92
94
AdcHandle .Init .Overrun = OVR_DATA_PRESERVED ;
93
95
AdcHandle .Init .LowPowerAutoWait = ENABLE ;
94
96
AdcHandle .Init .LowPowerFrequencyMode = DISABLE ; // To be enabled only if ADC clock < 2.8 MHz
95
- AdcHandle .Init .LowPowerAutoOff = ENABLE ;
97
+ AdcHandle .Init .LowPowerAutoOff = DISABLE ;
96
98
HAL_ADC_Init (& AdcHandle );
99
+
100
+ // Calibration
101
+ HAL_ADCEx_Calibration_Start (& AdcHandle , ADC_SINGLE_ENDED );
102
+
103
+ __HAL_ADC_ENABLE (& AdcHandle );
97
104
}
98
105
}
99
106
You can’t perform that action at this time.
0 commit comments