本帖最后由 Veiko 于 2015-1-14 14:29 编辑
在进入STOP模式前我对外部引脚作了配置,代码如下:
- void UserEnterLowPowerMode(void)
- {
- EXTI_InitTypeDef EXTI_InitStructure;
- GPIO_InitTypeDef GPIO_InitStructure;
- NVIC_InitTypeDef NVIC_InitStructure;
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB
- | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD
- | RCC_APB2Periph_AFIO, ENABLE);
- /* PA */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All - GPIO_Pin_0 - GPIO_Pin_8; /* 去掉GPIOA - PA0 */
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- /* PB */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- /* PC */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
- /* PD */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
- GPIO_Init(GPIOD, &GPIO_InitStructure);
-
-
- 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);/* 配置中断--清空标志位 */
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);/* Enable GPIOA clock */
-
- /* Configure PA.00 pin as input floating */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_8;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
-
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);/* Connect EXTI0 Line to PA.00 pin */
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource8);/* Connect EXTI8 Line to PA.08 pin */
- /* Configure EXTI0 line */
- EXTI_InitStructure.EXTI_Line = EXTI_Line0;
- EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
- EXTI_InitStructure.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStructure);
- /* Enable and set EXTI9-5 Interrupt to the lowest priority */
- NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
-
- /* Configure EXTI8 line */
- EXTI_InitStructure.EXTI_Line = EXTI_Line8;
- EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
- EXTI_InitStructure.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStructure);
- /* Enable and set EXTI8 Interrupt to the lowest priority */
- NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn ;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
- 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);/* 配置中断--清空标志位 */
-
- //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SRAM|RCC_AHBPeriph_FLITF, DISABLE);
- PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI); /* 进入停止模式 */
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); /* 使能AFIO时钟 */
- GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); /* 使用SWD,禁用JTAG,JTAG多余端口作IO使用 */
- SystemInit();
- UserHardWareInitize();
- Set_System();
- Set_USBClock();
- USB_Interrupts_Config();
- USB_Init();
-
- USB_PullUpResON();
- SEI();
- }
复制代码 中断中除了清标志外没有做任何操作的,以下是代码:- /**
- * @brief This function handles External line 0 interrupt request.
- * @param None
- * @retval None
- */
- void EXTI0_IRQHandler(void)
- {
- if(EXTI_GetITStatus(EXTI_Line0) != RESET)
- {
- /* Clear the EXTI line 0 pending bit */
- EXTI_ClearITPendingBit(EXTI_Line0);
- }
- }
- /**
- * @brief This function handles External line 0 interrupt request.
- * @param None
- * @retval None
- */
- void EXTI9_5_IRQHandler(void)
- {
- if(EXTI_GetITStatus(EXTI_Line5) != RESET)
- {
- /* Clear the EXTI line 5 pending bit */
- EXTI_ClearITPendingBit(EXTI_Line5);
- }
- else if(EXTI_GetITStatus(EXTI_Line6) != RESET)
- {
- /* Clear the EXTI line 6 pending bit */
- EXTI_ClearITPendingBit(EXTI_Line6);
- }
- else if(EXTI_GetITStatus(EXTI_Line7) != RESET)
- {
- /* Clear the EXTI line 7 pending bit */
- EXTI_ClearITPendingBit(EXTI_Line7);
- }
- else if(EXTI_GetITStatus(EXTI_Line8) != RESET)
- {
- /* Clear the EXTI line 8 pending bit */
- EXTI_ClearITPendingBit(EXTI_Line8);
- }
- else if(EXTI_GetITStatus(EXTI_Line9) != RESET)
- {
- /* Clear the EXTI line 9 pending bit */
- EXTI_ClearITPendingBit(EXTI_Line9);
- }
- }
复制代码
但PA0引脚的上升沿可以唤醒,PA8引脚的上升沿却不能唤醒,请大神帮忙解惑,不胜感激!
已解决,答案见16楼
|
PA0
PA8没有
PA8
根据芯片手册,在STOP模式下所有的EXTI引脚配置后都可以唤醒啊
现在就是不知道哪里配置错了,或者还有什么需要配置但却忘了配置的参数
额,这只是引脚名称,能不能唤醒不能只看这个,要看对应低功耗模式的唤醒条件才行啊,但条件里说可以唤醒的
ä½åè模å¼å¤é说æ表
我是参照这个图然后再看详细说明来做的,但可能哪里还没配好
中断中只清了标志位,代码已贴出来了,在1楼更新的,麻烦看一下
唤醒后是做了系统的重新配置的,中断在正常工作的模式下是可以进入的,现在就是不能唤醒而已
是不是人品问题呢?
有可能,看来要先出去扶老奶奶过马路后再来调