2025-05-29 6:50 AM
I'm using STM32L011F4P6 in CubeIDE. I toggle digital output pin PA2 hi/low every 10ms just to see if it works and it consumes 80uA when it runs. When I set another pin PA0 as analog input, the current consumption rises to 315uA. This is OK as I understand that it needs some energy to do ADC conversion. However I only need to measure analog input once and so I want to turn ADC off. I tried HAL_ADC_Stop(&hadc); HAL_ADC_DeInit(&hadc); however it does not returns consumption to 80uA only to 280uA, so something related to ADC is still on and consuming energy. I really want to go back to 80uA when I don't need ADC anymore. I tried enabling Auto Off it had no effect.
int x = 0;
while (1)
{
// toggle digital pin every 10ms
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_2);
HAL_Delay(10);
x++;
// at 5s mark (10ms*500 = 5s) turn off adc
if (x == 500) {
HAL_ADC_Stop(&hadc);
HAL_ADC_DeInit(&hadc);
}
}
2025-05-29 7:30 AM
I'm not familiar with the HAL, but do you also need to disable the ADC clock?
2025-05-29 7:38 AM
What is the correct way to disable ADC clock? I tried __HAL_RCC_ADC1_CLK_DISABLE(); and it had no effect, still 280uA.
2025-05-29 11:12 AM
>When I set another pin PA0 as analog input, the current consumption rises to 315uA
Really , when pin is analog mode ? -- It should need no power then !
So at first : find out, when the current is raising : on init, on setting pin..., on starting ADC.
And verify, its not another (unused) pin on same port, thats floating and so consumes power.
If its sure, the ADC is the cause and nothing else on this port:
Then 2 ways to find out , what needs the power (and then know, what to switch off):
- read rm, what is enabled , when using ADC (power to ADC, clock to ADC, battery sensor, int. reference, pin...).
- debug the HAL call, that starts increased power need, see, whats switched ON;
...then you know, what you have to switch off, for lowest power. And to switch on, to use the ADC again.