2014-03-30 05:01 PM
Hi i have a problem with interuption EXTI. I want to execute my principal function with an interuption with EXTI but it dosen't work ! only one instruction does work, this is my code. plz some one help me.
/*******************************************/
#include ''stm32f4xx_it.h''/*********************************************/2014-03-30 06:49 PM
It would have helped if there more context.
Make sure you've configured the pins, and that the GPIO and SYSCFG clocks are enabled. On a rising edge, you're likely to find the pin high when you enter the service routine.2014-03-31 03:45 PM
Dear Claude,
I did not get why you are trying to read PA3 in the interrupt handler ''EXTI3_IRQHandler''. Knowing that you configured the interrupt to be on the rising edge ''EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;'', you will find PA3 to be high as Clive1 stated. I will paste a piece of code that compiles and works fine: 1) replace the method EXTI_IRconfig with the following: void EXTILine3_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Enable GPIOA clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); /* Enable SYSCFG clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Configure PA3 pin as input floating */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Connect EXTI Line3 to PA3 pin */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource3); /* Configure EXTI Line3 */ EXTI_InitStructure.EXTI_Line = EXTI_Line3; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable and set EXTI Line3 Interrupt to the lowest priority */ NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } 2) call the function EXTILine3_Config(); in the ''main'' in order to configure the interrupt. 3) Provided that you properly configured GPIOD, you can use the code below for the interrupt handler to toggle PD15 void EXTI3_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line3) != RESET) { GPIO_ToggleBits(GPIOD, GPIO_Pin_15); EXTI_ClearITPendingBit(EXTI_Line3); } }2014-03-31 04:04 PM
I might suggest a slight different instruction sequence to avoid the pipeline hazard with tail-chaining.
void EXTI3_IRQHandler(void)
{
if (EXTI_GetITStatus(EXTI_Line3) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line3); // Do Early, avoid pipeline hazard
GPIO_ToggleBits(GPIOD, GPIO_Pin_15);
}
}
There are also F4 examples in the firmware library
STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\EXTI\EXTI_Example\main.c