External interrupts (falling edge) on PD.03 (INT_ARM) pin When the EXTI interrupt occurs PD.04 pin is toggled.
Toolkit:STM Development System
Location:/bipom/devtools/STM32/examples/exti
#include "exti.h" EXTI_InitTypeDef EXTI_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; volatile int G_led_state = 0; //******************************************************************************** int main (void) { tprintf("\n\rMini-Max/STM32F1"); tprintf("\n\rEXTI TEST REV 1.01"); /* Enable GPIOD clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); /* Configure PD.03 pin as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); /* Configure PD.04 pin as output */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); /* Enable AFIO clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); /* Connect EXTI Line to PD.03 pin */ GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3); /* Configure EXTI line */ 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); /* Enable and set EXTI0 Interrupt to the lowest priority */ NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); tprintf("\r\n"); for(;;); return 0; } //******************************************************************************** void EXTI3_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line3) != RESET) { if (1 & G_led_state++) { GPIOD_BSRR = 1UL<<(16+4); // Reset GPIO_Pin_4 tprintf("\r\nReset PD.04"); } else { GPIOD_BSRR = 1UL<<4; // Set GPIO_Pin_4 tprintf("\r\nSet PD.04"); } /* Clear the EXTI line 3 pending bit */ EXTI_ClearITPendingBit(EXTI_Line3); } } /* EOF */