cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030K6 Exit from sleep and stop mode

9056766
Associate II
Posted on December 10, 2015 at 10:23

Hi. Exit from sleep and stop mode not work. When STM32 in sleep mode and push to buttons on pins PA0, PA1, PA2, PA5, PA6, PA7, PA13 (low or high level) STM32 don't exit from sleep mode.

  sleep_counter++;

  if((sleep_counter>=400000)&&(lamp_start==0))

  { 

    GPIO_ResetBits(GPIOF, GPIO_Pin_0);  //A

    GPIO_ResetBits(GPIOF, GPIO_Pin_1);  //B

    GPIO_ResetBits(GPIOA, GPIO_Pin_3);  //C

    GPIO_ResetBits(GPIOB, GPIO_Pin_1);  //D

    GPIO_ResetBits(GPIOA, GPIO_Pin_9);  //E

    GPIO_ResetBits(GPIOA, GPIO_Pin_10);  //F

    GPIO_ResetBits(GPIOA, GPIO_Pin_13);  //G

    GPIO_SetBits(GPIOA, GPIO_Pin_14);  //DP

    

  PWR->CSR = PWR_CSR_EWUP1 | PWR_CSR_EWUP2 | PWR_CSR_EWUP5 | PWR_CSR_EWUP6 | PWR_CSR_EWUP7;

    RTC_AlarmTypeDef  RTC_AlarmStructure;

    RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);

    RTC_ITConfig(RTC_IT_ALRA, ENABLE);

    RTC_AlarmCmd(RTC_Alarm_A, ENABLE);

    PWR_WakeUpPinCmd(PWR_WakeUpPin_1,ENABLE);

  sleep_counter=0;

  // Clear Wakeup flag 

  PWR->CR |= PWR_CR_CWUF;

  // Select STANDBY mode 

  PWR->CR |= PWR_CR_PDDS;

  // Set SLEEPDEEP bit of Cortex-M0 System Control Register 

  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

  // Request Wait For Interrupt 

  __WFI();

  }

4 REPLIES 4
9056766
Associate II
Posted on December 11, 2015 at 08:28

Exit from stop mode not work. On low or high level on pins PA0, PA5, PA6, PA7, PA13.

EXTI line is configured.

//CWUF, PDDS and LPDS bits + SLEEPDEEP bit + WFI

PWR->CR |= 0x07;

SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

__WFI();

How to exit from stop mode by low level on pin PA5.

Posted on December 12, 2015 at 05:22

Sorry, not using the F030 here, may be you can expand your presentation to provide more context to the code, and the board you are using it on?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
9056766
Associate II
Posted on December 15, 2015 at 13:03

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6in&d=%2Fa%2F0X0000000bty%2Fh24VMXmmsadfmFLrvo9PlN4Qt3yiRdRT_gToSvUZ7Y0&asPdf=false
9056766
Associate II
Posted on December 21, 2015 at 07:50

Solved:

void Configure_PA0(void) 

{

    /* Set variables used */

    GPIO_InitTypeDef GPIO_InitStructure;

    EXTI_InitTypeDef EXTI_InitStructure;

    NVIC_InitTypeDef NVIC_InitStructure;

    // Enable clock for GPIOA 

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

    // Enable clock for SYSCFG 

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

    

    // Set pin as input 

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    //GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_0);  //

    

    // Tell system that you will use PA0 for EXTI_Line0 

    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);

  EXTI_ClearITPendingBit(EXTI_Line0 | EXTI_Line1 | EXTI_Line2 | EXTI_Line3 | EXTI_Line4

                          | EXTI_Line5 | EXTI_Line6 | EXTI_Line7 | EXTI_Line8

                          | EXTI_Line9 | EXTI_Line10 | EXTI_Line11 | EXTI_Line12

                          | EXTI_Line13 | EXTI_Line14 | EXTI_Line15 | EXTI_Line16

                          | EXTI_Line17 | EXTI_Line18 | EXTI_Line19 | EXTI_Line20

                          | EXTI_Line21 | EXTI_Line22 | EXTI_Line23 | EXTI_Line25

                          | EXTI_Line26 | EXTI_Line27 | EXTI_Line31);/**/

    // PA0 is connected to EXTI_Line0 

    EXTI_InitStructure.EXTI_Line = EXTI_Line0;

    // Enable interrupt 

    EXTI_InitStructure.EXTI_LineCmd = ENABLE;

    // Interrupt mode 

    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

    // Triggers on rising and falling edge 

    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;//EXTI_Trigger_Rising_Falling;

    // Add to EXTI 

    EXTI_Init(&EXTI_InitStructure);

 

    // �? �?°�?·Ñ€�?µÑˆ�?°�?µ�?¼ �?¿Ñ€�?µÑ€Ñ‹�?²�?°�?½�?¸Ñ� �?² �?¿�?µÑ€�?¸Ñ„�?µÑ€�?¸�?¸ �?´�?»Ñ� �?²Ñ‹�?²�?¾�?´�?¾�?² 0 

    EXTI->IMR |=(EXTI_IMR_MR0);

    

    // Add IRQ vector to NVIC 

    // PD0 is connected to EXTI_Line0, which has EXTI0_IRQn vector 

    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;

    // Set priority 

    NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;//NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0x00;

    // Set sub priority 

    //NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0x00;

    // Enable interrupt 

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    // Add to NVIC 

    NVIC_Init(&NVIC_InitStructure);

    NVIC_EnableIRQ(EXTI0_1_IRQn);

    NVIC_SetPriority(EXTI0_1_IRQn,0);

}

    DisableADC();

    Configure_PA0();

    sleep_counter=0;

  

   EXTI->FTSR = EXTI_FTSR_TR0;

   EXTI->IMR = 0;

   EXTI->EMR = EXTI_EMR_MR0;

   EXTI->PR = 0x0003FFFF;

   SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

   //PWR->CR &= ~(PWR_CR_PDDS|PWR_CR_LPDS);

   //PWR->CR |= PWR_CR_LPDS;

        PWR->CR |= 0x01; 

        EXTI->PR = 0x0003FFFF;

        __NOP();

   __WFE(); 

   NVIC_SystemReset();