cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_ADC_Init failed after wake up from STOP mode in STM32L0x2

honestech
Associate II

Hello, everyone.

I am trying to figure out the HAL_ADC_Init issue after wake up from STOP mode. I am using the STOP mode in STM32L0x2 and build the project using CubeMX.

At first, I have initialized ADC before main loop, then enter STOP mode. After wake up, re-initialized RCC and ADC. But the HAL_ADC_Init has failed and understood that there was HAL_ADC_STATE_ERROR_INTERNAL in HAL_ADC_Init().

  ...
  adc_init();
  while (1)
  {
    HAL_DBGMCU_EnableDBGStopMode();
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
    SystemClock_Config();
    adc_init();
  }

I have looked for the community thread, but there isn't the same case here.

Anyone has any idea? It would be appreciated.

Thanks in advance.

3 REPLIES 3

Hello

In stop mode Internal SRAM and register contents are preserved . No need to reinitialize the ADC and it is posible the initialization code is to give this error.

in case you need to reinitialize ADC, suggest to Deinitialize it first.

Hello, @Vangelis Fortounas (Community Member)​ 

Thanks for your reply.

I have already ADC Deinit code but missed it when posting.

Now it's my scenario, but still getting HAL ADC initializing error same as before.

  ...
  adc_init();
  while (1)
  {
    HAL_ADC_MspDeInit(&hadc);
    HAL_DBGMCU_EnableDBGStopMode();
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
    SystemClock_Config();
    adc_init();
  }

What would be workaround here?

Hello

at the end of deinitialization code set hadc1.state=0;