2020-09-29 06:46 PM
I am getting suspiciously high current draw (10mA) after I call
HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
and I'm trying to track down the culprit, I'm suspending the systick but it makes no change.
In stm32f0xx_hal.c it lists enabling/disabling debug during sleep (I am assuming to save power) as one of the included functions but only functions for stop mode and standby mode are included.
===============================================================================
##### HAL Control functions #####
===============================================================================
[..] This section provides functions allowing to:
(+) Provide a tick value in millisecond
(+) Provide a blocking delay in millisecond
(+) Suspend the time base source interrupt
(+) Resume the time base source interrupt
(+) Get the HAL API driver version
(+) Get the device identifier
(+) Get the device revision identifier
(+) Enable/Disable Debug module during Sleep mode
(+) Enable/Disable Debug module during STOP mode
(+) Enable/Disable Debug module during STANDBY mode
only these functions are listed
/**
* @brief Enable the Debug Module during STOP mode
* @retval None
*/
void HAL_DBGMCU_EnableDBGStopMode(void)
{
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
}
/**
* @brief Disable the Debug Module during STOP mode
* @retval None
*/
void HAL_DBGMCU_DisableDBGStopMode(void)
{
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
}
/**
* @brief Enable the Debug Module during STANDBY mode
* @retval None
*/
void HAL_DBGMCU_EnableDBGStandbyMode(void)
{
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
}
/**
* @brief Disable the Debug Module during STANDBY mode
* @retval None
*/
void HAL_DBGMCU_DisableDBGStandbyMode(void)
{
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
}
There is nothing listed in the bit definitions for this device (stm32f091xc.h) either. Is this just an omision by ST or is it not supported by the hardware?
2020-09-29 07:16 PM
I think the comment is a hold-over from other STM32 families. The L0 supports a debug module SLEEP mode, whereas the F0 only has this for the deep sleep modes STOP/STANDBY, where everything is otherwise turned off.
Is your system physically disconnected from the debug pod during these tests?
Are there any interrupts occurring with high regularity?
2020-09-29 07:29 PM
If a debugger had been attached, make sure if doesn't have anything enabled in the DBGMCU_APBx_FZ registers that would keep things ticking.
I'd probably look for external connectivity drawing current.
2020-09-29 07:37 PM
I get the 10mA current draw without the debugger attached.
I guess the assumption is that if you are using the sleep mode rather than the stop or standby you want the peripherals enabled but it would be nice to limit this to only the peripherals you actually need. I can DeInit the rest but as far as I can tell there is no DeInit for the debug module in the hal.
I'm using the ADC in DMA mode with a timer as a external trigger during sleep. Ideally the MCU should wake only on the analog watchdog interrupt but there is a chance that I have missed an interrupt elsewhere that could be waking the cpu, will take a closer look.
2020-09-29 07:41 PM
This was a similar L0 related post
2020-09-29 07:44 PM
There is a DBGMCUEN clock enable in RCC_APB2ENR, I'd expect that it is off by default