T_Usart1_Config(9600);
EXTIX_Init();
main()
{
while(1)
{
Delay_us(500);
GPIO_ResetBits(GPIOE,GPIO_Pin_12);
Delay_us(500);
GPIO_SetBits(GPIOE,GPIO_Pin_12);
}
}
void EXTI3_IRQHandler(void)
{
T_Sendschar(USART1,0xaa);//进中断就发AA
if(EXTI_GetITStatus(EXTI_Line3) != RESET)
{
}
EXTI_ClearITPendingBit(EXTI_Line3);
}
//中断线3
void EXTIX_Init(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* 开启AFIO的时钟 */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
//GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource9);
EXTI_InitStructure.EXTI_Line = EXTI_Line3; //中断线
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //中断模式
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //下降沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* 软件中断3号线*/
NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn; //使能按键所在的外部中断通道
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //抢占优先级为1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
。
复位后啥都不干串口一直发出AA
|