STM32L100Rc上退出STOP模式

问题描述 投票:1回答:1

我是使用STM32L100RC发现板的新编码器。因此,我的问题很简单。我无法使用唤醒引脚PA0上的外部触发器退出停止模式。该代码可以作为休假代码:PC9引脚上的LED点亮,我进入STOP MODE,一旦按下PA0按钮使用WakeUp命令,该LED就会熄灭几秒钟。现在,我知道使用for循环不是等待几秒钟的正确方法,无需指出这一点。如果有人可以解释我做错了,我将不胜感激。这是我到目前为止所做的:

void Button_Initialization (void)

{



RCC_APB2PeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);



// Configure PC9 as push-pull output

GPIO_InitTypeDef GPIO_InitStruct;

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9;

GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;

GPIO_Init(GPIOC, &GPIO_InitStruct);



GPIO_InitTypeDef GPIO_InitStructA;

GPIO_InitStructA.GPIO_Pin = GPIO_Pin_0;

GPIO_InitStructA.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructA.GPIO_Mode = GPIO_Mode_AF;

GPIO_PinAFConfig(GPIOA, GPIO_Pin_0, GPIO_AF_WKUP);

GPIO_Init(GPIOA, &GPIO_InitStructA);

PWR_WakeUpPinCmd(PWR_WakeUpPin_1, ENABLE);





GPIO_InitTypeDef GPIO_InitStructButton;

// GPIO_InitStructButton.GPIO_Pin = ;

GPIO_InitStructButton.GPIO_Speed = GPIO_Speed_400KHz;

GPIO_InitStructButton.GPIO_Mode = GPIO_Mode_IN;

GPIO_InitStructButton.GPIO_PuPd = GPIO_PuPd_DOWN;

GPIO_Init(GPIOA, &GPIO_InitStructButton);



EXTI_InitTypeDef EXTI_InitStruct;

EXTI_InitStruct.EXTI_Line = EXTI_Line1;

EXTI_InitStruct.EXTI_LineCmd = ENABLE;

EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Event;

EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;

EXTI_Init( &EXTI_InitStruct);

}



int main(void)

{

Button_Initialization();

while(1)

{

// Turn off LED on PC9

GPIO_SetBits(GPIOC, GPIO_Pin_9);





PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFE);


GPIO_ResetBits(GPIOC, GPIO_Pin_9);

for (int i = 0; i < 1000000; i++)

{

}

}

}
stm32 power-management stm32ldiscovery
1个回答
0
投票

使用您的配置,您没有唤醒源:

PWR_WakeUpPinCmd(PWR_WakeUpPin_1, ENABLE);仅在要将uC从待机模式唤醒而不是从停止模式唤醒时可用。 (请参阅参考手册的5.3.8 Standby mode5.4.2 PWR power control/status register (PWR_CSR)章)

通过进入像PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFE);这样的停止模式,您需要一个限定事件来唤醒uC。为此,您仅需在激活EXTI线路事件(即PA0)的情况下将EXTI line 0配置为输入(而不是备用唤醒功能)。

同样在进入停止模式之前,必须确保清除所有中断,EXTI线路和RTC挂起位。否则,进入停止模式将被忽略。

© www.soinside.com 2019 - 2024. All rights reserved.