From 71fd6519bc619866314281131be35e165cab7532 Mon Sep 17 00:00:00 2001 From: hogthrob Date: Fri, 8 Nov 2019 07:29:04 +0100 Subject: [PATCH] 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. --- src/adc_dma.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adc_dma.cpp b/src/adc_dma.cpp index a03a7c4..db9872b 100644 --- a/src/adc_dma.cpp +++ b/src/adc_dma.cpp @@ -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();