Skip to content

Commit 4378689

Browse files
committed
Reset internal vref buffer after an ADC conversion using the config channel function
1 parent a4ed473 commit 4378689

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

targets/TARGET_STM/TARGET_STM32L0/analogin_device.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,13 @@ uint16_t adc_read(analogin_t *obj)
175175
HAL_ADC_Start(&obj->handle); // Start conversion
176176

177177
// Wait end of conversion and get value
178+
uint16_t adcValue = 0;
178179
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
179-
return (uint16_t)HAL_ADC_GetValue(&obj->handle);
180-
} else {
181-
return 0;
182-
}
180+
adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
181+
}
182+
sConfig.Rank = ADC_RANK_NONE;
183+
HAL_ADC_ConfigChannel(&obj->handle, &sConfig);
184+
return adcValue;
183185
}
184186

185187
#endif

0 commit comments

Comments
 (0)