初中生
最后登录1970-1-1
在线时间 小时
注册时间2015-7-29
|
本帖最后由 小桥流水25 于 2015-10-20 17:59 编辑
最近学到了电源管理的睡眠实验,要用外部中断唤醒CPU,但是当初始化外部中断PC13时还开启了AFIO时钟,尝试把AFIO时钟关闭,就进入不了外部中断.
但是我看以前单独外部中断那一章初始化的是按键1(PA0),就没有开启AFIO时钟,在STM32中也没有找到相关的;作用,想问下,这是为什么?为什么要开启AFIO时钟?
- static void NVIC_Configuration(void)
- {
- NVIC_InitTypeDef NVIC_InitStructure;
-
- /* Configure one bit for preemption priority */
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
-
- /* ÅäÖÃP[A|B|C|D|E]13ÎaÖD¶ÏÔ′ */
- NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
-
-
-
- }
- /**
- * @brief ÅäÖà PC13ÎaÏßÖD¶Ï¿ú£¬2¢éèÖÃÖD¶ÏóÅÏ輶
- * @param ÎT
- * @retval ÎT
- */
- void EXTI_Key_Config(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- EXTI_InitTypeDef EXTI_InitStructure;
- /* config the extiline(PC13) clock and AFIO clock */
- <font color="#ff0000"> <b>RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO,ENABLE); //此处为什么要开启AFIO,看不懂?</b></font>
-
- /* config the NVIC(PC13) */
- NVIC_Configuration();
- /* EXTI line gpio config(PC13) */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; // éÏà-êäèë
- GPIO_Init(GPIOC, &GPIO_InitStructure);
-
- /* EXTI line(PC13) mode config */
- GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource13);
-
- EXTI_InitStructure.EXTI_Line = EXTI_Line13;
- EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
- EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //ϽμÑØÖD¶Ï
- EXTI_InitStructure.EXTI_LineCmd = ENABLE;
- EXTI_Init(&EXTI_InitStructure);
-
- }
复制代码 |
|