File tree Expand file tree Collapse file tree
L433C(B-C)(T-U)_L443CC(T-U)
L4R5Z(G-I)Y_L4R9Z(G-I)Y_L4S5ZIY_L4S9ZIY
STM32U5xx/U575O(G-I)YxQ_U585OIYxQ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -158,6 +158,14 @@ WEAK void SystemClock_Config(void)
158158 */
159159 __HAL_RCC_PWR_CLK_ENABLE ();
160160
161+ /* DBGMCU->CR debug bits (DBG_SLEEP, DBG_STOP, DBG_STANDBY) survive NRST
162+ * and are cleared only on VDD cycle. A prior SWD session can latch them,
163+ * leaving the debug subsystem clocked in STOP/STANDBY on every subsequent
164+ * warm reboot (hundreds of uA). Scrub them on every boot.
165+ */
166+ CLEAR_BIT (DBGMCU->CR ,
167+ DBGMCU_CR_DBG_SLEEP | DBGMCU_CR_DBG_STOP | DBGMCU_CR_DBG_STANDBY);
168+
161169 /* Voltage scaling - Scale 1 required for SYSCLK = 80 MHz
162170 * RM0394 s.5.1.7: VOS2 supports up to 26 MHz only
163171 */
Original file line number Diff line number Diff line change @@ -190,6 +190,14 @@ WEAK void SystemClock_Config(void)
190190 */
191191 __HAL_RCC_PWR_CLK_ENABLE ();
192192
193+ /* DBGMCU->CR debug bits (DBG_SLEEP, DBG_STOP, DBG_STANDBY) survive NRST
194+ * and are cleared only on VDD cycle. A prior SWD session can latch them,
195+ * leaving the debug subsystem clocked in STOP/STANDBY on every subsequent
196+ * warm reboot (hundreds of uA). Scrub them on every boot.
197+ */
198+ CLEAR_BIT (DBGMCU->CR ,
199+ DBGMCU_CR_DBG_SLEEP | DBGMCU_CR_DBG_STOP | DBGMCU_CR_DBG_STANDBY);
200+
193201 /* Voltage scaling - Scale 1 Boost required for SYSCLK = 120 MHz
194202 * RM0432 s.5.1.8: "In Range 1 boost mode (R1MODE = 0), the maximum system
195203 * clock frequency is 120 MHz"
Original file line number Diff line number Diff line change @@ -206,6 +206,19 @@ WEAK void SystemClock_Config(void)
206206 */
207207 __HAL_RCC_PWR_CLK_ENABLE ();
208208
209+ /* * Clear DBGMCU low-power-mode latch bits
210+ *
211+ * ST-Link and IDEs set DBG_STOP and DBG_STANDBY on debugger attach to keep
212+ * the SWD link alive across low-power mode entry. These bits survive NRST,
213+ * watchdog, and software reset, and only clear on a true VDD cycle. If
214+ * left set in the field, the debug subsystem stays clocked in STOP2 and
215+ * adds hundreds of uA.
216+ *
217+ * On STM32U5 only DBG_STOP and DBG_STANDBY exist in DBGMCU->CR; there is
218+ * no DBG_SLEEP bit on the Cortex-M33 debug architecture.
219+ */
220+ CLEAR_BIT (DBGMCU->CR , DBGMCU_CR_DBG_STOP | DBGMCU_CR_DBG_STANDBY);
221+
209222 /* * Select SMPS as the Vcore regulator
210223 *
211224 * The STM32U575OIY6QTR (Q-suffix) exposes the dedicated SMPS pinout, and
You can’t perform that action at this time.
0 commit comments