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:
+1
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user