Hi,
We would like to drive pin PWR_ON to low for low power mode.
First, on MCU, we use HAL library: HAL_PWR_EnterSTANDBYMode(), load to M4 and run it first, so M4 now enter standby mode.
Second, on MPU, we set TZEN=0 so non-secure, allow us to modify PWR and RCC registers.
We write a small application, using devmem to change registers, code is below:
...
int main() {
Register.SetBits(PWR_MPUCR, 1 << 9); //PWR_MPUCR_CSSF
Register.SetBits(PWR_MPUCR, 1 << 3); //PWR_MPUCR_CSTBYDIS
Register.SetBits(PWR_MPUCR, 1 << 0); //PWR_MPUCR_PDDS
Register.SetBits(PWR_CR1, 1 << 0); //LPDS
Register.SetBits(PWR_CR1, 1 << 1); //LPCFG
Register.SetBits(PWR_CR1, 1 << 2); //LVDS
Register.Write(RCC_MP_SREQSETR, 1 << 0);//RCC_MP_SREQSETR_STPREQ
Register.Write(RCC_MP_RSTSCLRR, 0x7FF);//RCC_MP_RSTSCLRR => clear reset flags
__asm volatile ("dsb" : : : "memory");
__asm volatile ("isb" : : : "memory");
__asm volatile("wfi" : : : "memory");; // wait for interrupt
return 0; // should not be here
}
Problem is, when run application from command prompt, nothing happened, PWR_ON pin still high and wfi() seems not work, the application return 0.
We checked PWR_MPUCR register and see the values we write into register are correct.