cancel
Showing results for 
Search instead for 
Did you mean: 

How to return to RUN mode from STOP2 mode ?

Maunik Patel
Associate II

Hello there,

I am working on STM32L432KB's Power saving modes and currently testing STOP2 Mode.

After reading reference manual I made the code below to Enter and Exit from STOP2 Mode.

My Goal is to enter Stop2 mode when a button is pressed and get back to RUN mode when another interrupt is generated.

Here, main thing to consider is, I am using MSI Clock at 48MHz, and I want previously configured MSI clock at 48Hz clock frequency when we Exit from STOP2 Mode.

Here, I tried to configure two interrupts.

1st one is to enter in STOP2 Mode

2nd is to Exit from the same with MSI clock at 48MHz.

Please review the code below.

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
 
    // Here, I am generating button interrupt, which will make MCU to go in Stop2 Mode
    if(GPIO_Pin == SWITCH_EXTI5_Pin){
        
        // Enable Debugging in LPM
        SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
 
        // to Select MSI 48MHz when Exiting from Stop2 Mode
        CLEAR_BIT(RCC->CFGR, RCC_CFGR_STOPWUCK);
 
        HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
    }
 
    // We have configured another interrupt which, I think, will get the MCU back in RUN mode. No code for this portion.
    if(GPIO_Pin == GPIO_PIN_1){
    }
}

This code Enters in STOP2 mode, which I can see by debugging window.

But, when I generate another interrupt to Exit from STOP2 Mode, I can't go back in RUN mode.

Can any one inform me if I am going in right direction or not?

Please guide me if you find me doing some mistakes.

Thank You,

Maunik Patel

0 REPLIES 0