2021-01-21 07:42 AM
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.
2021-01-21 11:33 AM
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.
2021-01-21 06:55 PM
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?
2021-01-22 02:09 AM
Hello
at the end of deinitialization code set hadc1.state=0;