学前班
最后登录1970-1-1
在线时间 小时
注册时间2015-1-23
|
本帖最后由 热情的坚果 于 2015-4-22 16:27 编辑
static void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* ÅäÖÃÖD¶ÏÔ′ */
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* ÅäÖÃ[A|B|C|D|E]13ÎaÖD¶ÏÔ′ */
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}EXTI_InitTypeDef EXTI0_InitStructure;
void EXTI_PA0_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* config the extiline clock and AFIO clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO,ENABLE);
/* config the NVIC */
NVIC_Configuration();
/* EXTI line gpio config*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; // ÏÂà-êäèë
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* EXTI line mode config */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
EXTI0_InitStructure.EXTI_Line = EXTI_Line0;
EXTI0_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI0_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //éÏéyÑØÖD¶Ï
EXTI0_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI0_InitStructure);
}
EXTI_InitTypeDef EXTI1_InitStructure;
void EXTI_PB1_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* config the extiline clock and AFIO clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO,ENABLE);
/* config the NVIC */
NVIC_Configuration();
/* EXTI line gpio config*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; // ÏÂà-êäèë
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* EXTI line mode config */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource1);
EXTI1_InitStructure.EXTI_Line = EXTI_Line1;
EXTI1_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI1_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //éÏéyÑØÖD¶Ï
EXTI1_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI1_InitStructure);
}
这么配置PA0和PB1口外部中断可以吗?为什么没有只有PA0外部中断有反应?
这样配置两个外部中断可以吗?为什么
|
|