Search code examples
stm32temperatureadchal

STM32 Temperature sensor power off


I am using internal ADC temp sensor , in a low power device without the sensor in stop mode ,the uController consumes around 4 uA but when the temp sensor is on the consumption goes up to 8-9 uA the problem is i can not turn the sensor OFF / i just measured the off current by setting it off from start by stmcube

i am searching for a code that can turn off the temp sensor up until now i have tested these:

1-

HAL_ADC_Init(&hadc);
hadc.Lock=HAL_UNLOCKED;
__HAL_UNLOCK(&hadc);
HAL_ADCEx_DisableVREFINTTempSensor();

2-

ADC1->CR&=0X00000000;
ADC->CCR&=~(1<<23);

i prefer to work with HAL , it dose not seems to cut the Sensor power


Solution

  • Your ADC1->CR &= 0x00000000; line looks wrong to me, depending on the controller you're using.

    There is usually a bit to disable the ADC which needs to be set, rather than writing all 0s. Try ADC1->CR = (0x01 << 1); instead. If you have the ST Micro written defines for your processor ADC1->CR = ADC_CR_ADDIS; should be the same but more readable. After disabling the ADC you will be able to turn off the TSEN bit of ADC->CCR.