Fix for ADC randomly misconfigured (#74)

This issue happened because the HAL ADC configuration data structure
is allocated on the stack (which by default is not initialized,
i.e. contains potentially non-zero data). As most of this structure was
explicitly initialized only sometimes the OversampleMode setting was
not 0, in this case the ADC had no left data alignment, i.e. delivered
too low values. If it happens, the system sees very weird temperature 
and voltage/power values.
This commit is contained in:
hogthrob
2019-11-08 07:29:04 +01:00
committed by Martin Jäger
parent 328215dc8e
commit 71fd6519bc
+1 -1
View File
@@ -349,7 +349,7 @@ void adc_setup()
solar_en = 1;
#endif
ADC_HandleTypeDef hadc;
ADC_HandleTypeDef hadc = {0};
ADC_ChannelConfTypeDef sConfig = {0};
__HAL_RCC_ADC1_CLK_ENABLE();