Skip to content

Commit 363f35f

Browse files
authored
Merge pull request #9560 from RobVlaar/analogin-fix-stm32l0xx
Reset internal vref buffer after an ADC conversion
2 parents a0c4646 + fa68d43 commit 363f35f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

targets/TARGET_STM/TARGET_STM32L0/analogin_device.c

Lines changed: 5 additions & 3 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;
180+
adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
182181
}
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)