Skip to content

Commit 90fd6cd

Browse files
author
Cruz Monrreal
authored
Merge pull request ARMmbed#9252 from jeromecoutant/PR_L4VBAT
STM32L4 ADC : power optimisation for VBAT channel
2 parents c580260 + 164fee0 commit 90fd6cd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

targets/TARGET_STM/TARGET_STM32L4/analogin_device.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ uint16_t adc_read(analogin_t *obj)
193193

194194
// Wait end of conversion and get value
195195
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
196+
197+
/* Ref Manual: To prevent any unwanted consumption on the battery,
198+
it is recommended to enable the bridge divider only when needed for ADC conversion */
199+
if (sConfig.Channel == ADC_CHANNEL_VBAT) {
200+
CLEAR_BIT(__LL_ADC_COMMON_INSTANCE(obj->handle.Instance)->CCR, LL_ADC_PATH_INTERNAL_VBAT);
201+
}
202+
196203
return (uint16_t)HAL_ADC_GetValue(&obj->handle);
197204
} else {
198205
return 0;

0 commit comments

Comments
 (0)