Is this the right way to "shut down" a 32F417?
I am implementing a data save procedure when power fail is detected and want to shut down as much stuff as possible to give myself the most time to copy some data into FLASH.
Shutting down the CPU has many modes which are quite complicated. I have been reading the RM and various appnotes. Googling around shows a lot of people are having problems.
Is this a right way to do it? It never needs to come out of it, and it must not come out of it for any interrupt
CLEAR_BIT(PWR->CSR, 0x00000100U); // disable WKUP pin, just in case
#define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )
portNVIC_SYSTICK_CTRL_REG = 0UL; // stop systick, just in case (also stops RTOS)
SET_BIT(PWR->CR, PWR_CR_PDDS); // select standby mode
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); // Set SLEEPDEEP bit
__WFI(); // request "wait for interrupt"Some of the above is out of HAL_PWR_EnterSTANDBYMode().
I don't get what __WFI is supposed to do.
Thank you for any help or suggestions.