Skip to main content
honestech
Associate II
January 21, 2021
Question

HAL_ADC_Init failed after wake up from STOP mode in STM32L0x2

  • January 21, 2021
  • 3 replies
  • 1602 views

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.

This topic has been closed for replies.

3 replies

Vangelis Fortounas
Associate II
January 21, 2021

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.

honestech
honestechAuthor
Associate II
January 22, 2021

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?

Vangelis Fortounas
Associate II
January 22, 2021

Hello

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