Can't read AnalogIn after wake up from deepsleep

21 May 2015

Hi

I use a Nucleo L152RE and try reading the ADC after a wake up from stop mode using the deepsleep function.

This returns 0.0000. I have tried in sleep mode, and this works fine.

I have also tried reinitializing the AnalogIn object.

Have no idea why this isn't working and would really appreciate if someone know how to solve this.

Håkon

08 Jun 2015

I saw the same issue, you have to reinitialize the HSI clock, because that's what the ADC is setup to use. The below code will get the HSI running again.

// Enable the HSI (to clock the ADC)
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState       = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState   = RCC_PLL_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);