Skip to main content
Visitor II
July 9, 2025
Solved

STM32F405: exit low power STOP mode on external interrupt pin

  • July 9, 2025
  • 2 replies
  • 501 views

Hello,

I want to use the PB6 pin as an external interrupt input. When the PB6 pin is triggered, the program enters the low-power stop mode from the normal operation mode. When it is triggered again, the program enters the normal operation mode from the low-power stop mode. According to the above, the test found that after the program enters the low-power mode, it cannot return to the normal operation mode again.

 

Does anyone have experience in this area and can provide me with a solution?

    This topic has been closed for replies.
    Best answer by lan1

    @QSHAO.1  @TDK   hello I configured PB6 as an external input interrupt. The configuration is as follows, and I am certain that this function is normal and effective.

    EXTI_InitTypeDef EXTI_InitStructure;
     NVIC_InitTypeDef NVIC_InitStructure;
    
    
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
    
    
     SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource6);
    
     EXTI_InitStructure.EXTI_Line = EXTI_Line6;
     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
     EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
     EXTI_InitStructure.EXTI_LineCmd = ENABLE;
     EXTI_Init(&EXTI_InitStructure);
    
     NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    
    
     NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;
     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03;
     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
     NVIC_Init(&NVIC_InitStructure);

     And I placed the low-power mode in the time slice polling. Meanwhile, the PB6 pin is self-resetting and will only be triggered once at a time.

     PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
     SystemInit();

    2 replies

    Super User
    July 9, 2025

    Don't enter low-power mode from within an interrupt. Set a flag and do it in the main thread.

    Additionally, if this is a button, you will probably have to debounce it.

    ST Employee
    July 9, 2025

    Some information about how to exist stop mode (refer to RM0090), hope it's helpful.

    If WFI or Return from ISR was used for entry:
    Any EXTI lines configured in Interrupt mode (the corresponding EXTI
    Interrupt vector must be enabled in the NVIC). The interrupt source can
    be external interrupts or peripherals with wake-up capability.

     
    If WFE was used for entry and SEVONPEND = 0
    Any EXTI lines configured in event mode.

     

    If WFE was used for entry and SEVONPEND = 1:
    – Any EXTI lines configured in Interrupt mode (even if the corresponding
    EXTI Interrupt vector is disabled in the NVIC). The interrupt source can
    be an external interrupt or a peripheral with wake-up capability. 

     

    lan1AuthorAnswer
    Visitor II
    July 9, 2025

    @QSHAO.1  @TDK   hello I configured PB6 as an external input interrupt. The configuration is as follows, and I am certain that this function is normal and effective.

    EXTI_InitTypeDef EXTI_InitStructure;
     NVIC_InitTypeDef NVIC_InitStructure;
    
    
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
    
    
     SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource6);
    
     EXTI_InitStructure.EXTI_Line = EXTI_Line6;
     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
     EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
     EXTI_InitStructure.EXTI_LineCmd = ENABLE;
     EXTI_Init(&EXTI_InitStructure);
    
     NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    
    
     NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;
     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03;
     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
     NVIC_Init(&NVIC_InitStructure);

     And I placed the low-power mode in the time slice polling. Meanwhile, the PB6 pin is self-resetting and will only be triggered once at a time.

     PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
     SystemInit();
    Super User
    July 9, 2025

    Show your full code.