Skip to main content
Geoffrey1
Associate III
Aug 1, 2026 8:54 PM UTC
Question

Flash writes fail after exiting stop3 on stm32u375

I have an application that uses internal flash for logging.  Unfortunately, after exiting stop3 subsequent writes to flash fail.  Here’s my exit code -- the names of the routines should give a general idea.  I don’t really have a clue what changed and the reference manual is notably sparse on details about the various stop/standby/shutdown modes

 


SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));

__DSB();
__WFI();
__ISB();

CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
PWR->APCR &= ~PWR_APCR_APC;
palSetLine(LINE_testpin);

chSysLock();
tagPowerRestoreClocksAfterStop3();
tagPowerPostStop3WakeEventI();
chSysUnlock();
// Ensure Flash is awake and not stuck in low-power mode
FLASH->ACR &= ~(FLASH_ACR_SLEEP_PD);
__DSB();

 

3 replies

KDJEM.1
ST Technical Moderator
Sep 16, 2026 11:07 AM UTC

Hello ​@Geoffrey1;

 

First of all I apologize for my late reply.

Do you get the same issue when starting from an available example PWR_STOP3?

For more information about power consumption modes, I recommend you to look at RM0487 section 9.3.5 PWR power management and the datasheet.

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.
KDJEM.1
ST Technical Moderator
Nov 2, 2026 1:16 PM UTC

Hello ​@Geoffrey1 ,

 

Any update? 

Is the issue solved?

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.
Geoffrey1
Geoffrey1Author
Associate III
Nov 2, 2026 1:26 PM UTC

Yes, but it’s been a while.  Here’s what I ended up doing (besides restarting clocks and power mode):

 

/**

* @brief Return STM32U3 flash control/status to run-ready state after Stop3.

*/

static inline void tagPowerRestoreFlashAfterStop3(void)

{MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, 3U);

uint32_t acr_clear = 0U;

uint32_t sr_clear = 0U;

uint32_t sr_powerdown = 0U;

 

#if defined(FLASH_ACR_LPM)

acr_clear |= FLASH_ACR_LPM;

#endif

#if defined(FLASH_ACR_PDREQ1)

acr_clear |= FLASH_ACR_PDREQ1;

#endif

#if defined(FLASH_ACR_PDREQ2)

acr_clear |= FLASH_ACR_PDREQ2;

#endif

#if defined(FLASH_ACR_SLEEP_PD)

acr_clear |= FLASH_ACR_SLEEP_PD;

#endif

if (acr_clear != 0U) {

CLEAR_BIT(FLASH->ACR, acr_clear);

}

 

#if defined(FLASH_SR_PD1)

sr_powerdown |= FLASH_SR_PD1;

#endif

#if defined(FLASH_SR_PD2)

sr_powerdown |= FLASH_SR_PD2;

#endif

for (uint32_t timeout = 1024U;

timeout > 0U && ((FLASH->SR & sr_powerdown) != 0U);

timeout--) {

__NOP();

}

 

sr_clear = TAG_U3_FLASH_SR_ERROR_MASK;

WRITE_REG(FLASH->SR, sr_clear);

}