STM32F407 STOP MODE FAILURE
Hi everyone,
I am facing a bizarre issue with an STM32F407 running a custom PCB. I am trying to put the MCU into STOP mode (Low Power Regulator ON), but it seems to enter deep sleep for a fraction of a second (current drops to almost 0mA) and then immediately wakes up/resets, stabilizing at a constant 9.8mA.
I am programming via DFU and using a custom bootloader that jumps to the main application at 0x08010000.
Here is what I have already done in my "Deep Sleep Test" routine to isolate the issue:
-
Hardware Isolation: All external peripherals (W25Q Flash, FRAM, LDOs) are completely disconnected or powered down. The 3.3V line is isolated.
-
GPIOs: All GPIOs are set to
GPIO_MODE_ANALOG, except for specific pull-up/pull-down pins strictly required by the hardware. -
USB PHY: I am explicitly disabling the internal USB transceiver using
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_PWRDWN;and then disabling the clock. -
Interrupts & SysTick: I disable
SysTick->CTRL = 0, clearSCB->ICSR, mask all EXTI lines (EXTI->IMR = 0), and explicitly disable/clear all NVIC lines usingNVIC->ICER[i] = 0xFFFFFFFFandNVIC->ICPR[i] = 0xFFFFFFFF. -
RTC/Watchdog: I freeze the IWDG in STOP mode using
__HAL_DBGMCU_FREEZE_IWDG();and I force a backup domain reset to clear any ghost RTC wakeups.
Despite all this, calling HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); inside a while(1) loop results in a momentary drop to 0mA, followed by an immediate return to 9.8mA.
My suspicion is that the custom bootloader is leaving some peripheral active or a pending flag that completely bypasses my NVIC disabling, or I am triggering a Brown-Out Reset during the current drop.
Has anyone experienced this "instant bounce" back to 10mA on the F4 series? What hidden registers should I check before calling WFI?
Thanks in advance for any pointers!
