Skip to content

Commit c5b277f

Browse files
LMESTM0xc0170
authored andcommitted
STM32WB: ADC INTERNAL CHANNEL reset after read
Internal channels use is enabling ADC "internal path" which needs to be disabled after measurement. Same applied here for WB family as was done for others in #10143.
1 parent defa75a commit c5b277f

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

targets/TARGET_STM/TARGET_STM32WB/analogin_device.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,12 @@ uint16_t adc_read(analogin_t *obj)
190190
}
191191

192192
// Wait end of conversion and get value
193+
uint16_t adcValue = 0;
193194
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
194-
195-
/* Ref Manual: To prevent any unwanted consumption on the battery,
196-
it is recommended to enable the bridge divider only when needed for ADC conversion */
197-
if (sConfig.Channel == ADC_CHANNEL_VBAT) {
198-
CLEAR_BIT(__LL_ADC_COMMON_INSTANCE(obj->handle.Instance)->CCR, LL_ADC_PATH_INTERNAL_VBAT);
199-
}
200-
201-
return (uint16_t)HAL_ADC_GetValue(&obj->handle);
202-
} else {
203-
debug("ADC conversion failed. Returned 0.\r\n");
204-
return 0;
195+
adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
205196
}
197+
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE((&obj->handle)->Instance), LL_ADC_PATH_INTERNAL_NONE);
198+
return adcValue;
206199
}
207200

208201
const PinMap *analogin_pinmap()

0 commit comments

Comments
 (0)