本帖最后由 kangbin334 于 2015-9-4 23:14 编辑
#include "stm32f10x.h"
#include "led.h"
#include "delay.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_it.h"
int main(void)
{
led_init();
delay_init();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOC,ENABLE);
GPIO_EventOutputConfig(GPIO_PortSourceGPIOC,GPIO_PinSource0);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
EXTI_InitTypeDef aaa;
aaa.EXTI_Line=EXTI_Line0;
aaa.EXTI_LineCmd=ENABLE;
aaa.EXTI_Mode=EXTI_Mode_Interrupt;
aaa.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_Init(&aaa);
NVIC_InitTypeDef bbb;
bbb.NVIC_IRQChannel=EXTI0_IRQn;
bbb.NVIC_IRQChannelCmd=ENABLE;
bbb.NVIC_IRQChannelPreemptionPriority=0;
bbb.NVIC_IRQChannelSubPriority=0;
NVIC_Init(&bbb);
EXTI_ClearITPendingBit(EXTI_Line0);
while(1);
}
void EXTI0_IRQHandler(void)
{
GPIOF->ODR=0xfffd;
EXTI_ClearFlag(EXTI_Line0);
EXTI_ClearITPendingBit(EXTI_Line0);
}
这个程序什么都不用改,只要把中断口PC0换成PA0就能进中断,而且现在是只有PA0能进中断。
|