AnsweredAssumed Answered

STM32103 will not wakeup from sleep

Question asked by ratterman.michael on Aug 27, 2013
Latest reply on Oct 1, 2013 by ratterman.michael
Hi,

I am having some issue with STOP mode and waking up on my STM32 device.

Here is my code to enable my button input:

// Button input - enable pull-down
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);


Here is my sleep function:

void WaitForPowerUp(void)
{
  uint16_t bstate, pushed = 0;
  EXTI_InitTypeDef EXTI_InitStructure;
  
  //EXTI_DeInit(); // was commented out
  SleepLSR();
   
  /* Connect Button EXTI Line to Button GPIO Pin */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_Pin_0);
   
  /* Configure Button EXTI line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line0;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
     
  while(1) {
     
    SysTickDisable();
     
    // setup button input as wakeup
    PWR_WakeUpPinCmd(ENABLE);
    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFE);
     
    // exit STOP, re-enable clocks
    SYSCLKConfig_STOP();
    PWR_WakeUpPinCmd(DISABLE);
         
    // pushbutton change should restart CPU here
    bstate = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0);
         
    SysTickConfig();
    // time button press..
    while(bstate == 1) {
      DelayMs(10);
      bstate = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0);
      if(++pushed > 500) {
        EXTI_InitStructure.EXTI_LineCmd = DISABLE;
        EXTI_Init(&EXTI_InitStructure);
        return;
      }
    }
    pushed = 0;
  }
   
}

This seems to work fine.. however I am trying to set all of the inputs to analog so I can reduce current consumption while in STOP mode.

The problem is when I insert this code:

/* Enable GPIOs clock */
   
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
    RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
    RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF, ENABLE);
   
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  //GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_Init(GPIOD, &GPIO_InitStructure);
  GPIO_Init(GPIOF, &GPIO_InitStructure);
  GPIO_Init(GPIOE, &GPIO_InitStructure);
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  GPIO_Init(GPIOB, &GPIO_InitStructure);
   
   
  // Button input - enable pull-down
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
  GPIO_Init(GPIOA, &GPIO_InitStructure);



If I insert this then I cannot wake up from sleep.. I am not sure what I am doing wrong.

Thanks

Mike

Outcomes