Skip to content

Commit d64d309

Browse files
committed
[HAL][ADC] Change ADC calibration procedure
1 parent 5d1d233 commit d64d309

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Src/stm32c0xx_hal_adc_ex.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,13 @@ HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef *hadc)
166166
return HAL_ERROR;
167167
}
168168
}
169-
170-
calibration_factor_accumulated += LL_ADC_GetCalibrationFactor(hadc->Instance);
169+
/* Read the calibration factor and increment by one */
170+
calibration_factor_accumulated += (LL_ADC_GetCalibrationFactor(hadc->Instance) + 1UL);
171171
}
172-
/* Compute average */
172+
/* Compute average (rounded up to the nearest integer) */
173+
calibration_factor_accumulated += (calibration_index / 2UL);
173174
calibration_factor_accumulated /= calibration_index;
175+
174176
/* Apply calibration factor (requires ADC enable and disable process) */
175177
LL_ADC_Enable(hadc->Instance);
176178

0 commit comments

Comments
 (0)