Skip to content

STM32L4 ADC : power optimisation for VBAT channel #9252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions targets/TARGET_STM/TARGET_STM32L4/analogin_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ uint16_t adc_read(analogin_t *obj)

// Wait end of conversion and get value
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {

/* Ref Manual: To prevent any unwanted consumption on the battery,
it is recommended to enable the bridge divider only when needed for ADC conversion */
if (sConfig.Channel == ADC_CHANNEL_VBAT) {
CLEAR_BIT(__LL_ADC_COMMON_INSTANCE(obj->handle.Instance)->CCR, LL_ADC_PATH_INTERNAL_VBAT);
}

return (uint16_t)HAL_ADC_GetValue(&obj->handle);
} else {
return 0;
Expand Down