各位大侠,之前我用PB0口作唤醒键可以成功唤醒休眠后的STM32F030,因为项目需求,要改成用PB14来唤醒,但我将程序改成PB14后就唤不醒STM32F030,不知道为什么,请各位大侠指点一下,十分感谢!
void MCU_EnterSTOPMode(void) //MCU进入停机模式
{
uint8_t temp;
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStruct;
GPIO_SetBits(GPIOB,GPIO_Pin_13); //熄灭工作指示灯
//================================== TIM16 OFF ===========================================
TIM_ITConfig(TIM16, TIM_IT_Update, DISABLE);
TIM_ClearITPendingBit(TIM16, TIM_IT_Update);
NVIC_InitStructure.NVIC_IRQChannel = TIM16_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_ClearITPendingBit(TIM16, TIM_IT_Update);
TIM_DeInit(TIM16);
//Select HSI as system clock source
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_HSI;
//Wait till HSI is used as system clock source
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_HSI)
{
}
//Disable PLL
RCC->CR &= ~RCC_CR_PLLON;
//Wait till PLL off
while((RCC->CR & RCC_CR_PLLRDY) != 0)
{
}
//Enable SYSCFG clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
EXTI_ClearITPendingBit(EXTI_Line14);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource14);
EXTI_InitStruct.EXTI_Line = EXTI_Line14;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //上升沿下降沿中断
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); //开电源管理时钟
// Request to enter STOP mode with regulator in low power mode
PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);
////////////////////////////////////////////////////////////////////////////////////
for( temp = 10; temp != 0; temp-- );
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource14);
EXTI_InitStruct.EXTI_Line = EXTI_Line14;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //上升沿下降沿中断
EXTI_InitStruct.EXTI_LineCmd = DISABLE;
EXTI_Init(&EXTI_InitStruct);
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure);
EXTI_ClearITPendingBit(EXTI_Line14);
GPIO_ResetBits(GPIOB,GPIO_Pin_13); //点亮工作指示灯
}
|