cancel
Showing results for 
Search instead for 
Did you mean: 

STM32103 will not wakeup from sleep

meratterman
Associate II
Posted on August 27, 2013 at 22:10

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
4 REPLIES 4
Posted on August 27, 2013 at 22:26

I am not sure what I am doing wrong.

 

Dunno, you got any pins that need to be outputting specific values? Do those have external pull ups/downs so they don't break? JTAG/SWD? Check for board dependencies.

How about physically excluding PA0 from reprogramming. ie Do GPIOA bank last, and mask off GPIO_Pin_0

The F1 is very sensitive to the state of PA0 prior to going to sleep, as I recall if it's already asserted, a reassertion later will be ignored.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
meratterman
Associate II
Posted on August 27, 2013 at 23:31

clive1,

Thank you for your reply, I tried what you suggested but the chip still does not wakeup.  If I omit the analog configuration, it goes to sleep and wakes up ok, however it is using about 3mA of current.  It seems that the analog configuration is the cause of the excessive current draw during sleep, however button interrupt does not wake it up anymore.

Posted on August 28, 2013 at 02:47

Do some quick bisection of the which GPIO bank(s)/pin(s) in analogue cause a problem.

ST suggests using AIN because it disables all digital on the pad, including the schmitt trigger input. Other vendors of low power parts suggest enabling digital output of zero, as it stops oscillations on the pins.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
meratterman
Associate II
Posted on October 01, 2013 at 21:57

clive1,

Are you available for outside billable help on this problem?  If interested, please respond to meratterman@gmail.com

Thanks