cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with STM32F4.7 External Interrupt

RShar.17
Associate II

Dear All,

i configured an input pin as external interrupt with rising edge detection and pulled it down internally.

i apply a pulse train which it sets and resets within the time that the interrupt is disabled.

i expect that the ISR executes when it is enabled. but it doesn't response to disabling it and continue triggering.

do you know about the reason?

thanks in advance.

please consider the code in the following:

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};

 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 /** Configure the main internal regulator output voltage

 */

 __HAL_RCC_PWR_CLK_ENABLE();

 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

 /** Initializes the CPU, AHB and APB busses clocks

 */

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_ON;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM = 8;

 RCC_OscInitStruct.PLL.PLLN = 144;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

 RCC_OscInitStruct.PLL.PLLQ = 4;

 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

   Error_Handler();

 }

 /** Initializes the CPU, AHB and APB busses clocks

 */

 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

                             |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)

 {

   Error_Handler();

 }

}

static void MX_GPIO_Init(void)

{

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* GPIO Ports Clock Enable */

 __HAL_RCC_GPIOF_CLK_ENABLE();

 __HAL_RCC_GPIOH_CLK_ENABLE();

 __HAL_RCC_GPIOA_CLK_ENABLE();

 __HAL_RCC_GPIOB_CLK_ENABLE();

 GPIO_InitStruct.Pin = in1_Pin;

 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

 GPIO_InitStruct.Pull = GPIO_PULLDOWN;

 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

 /* EXTI interrupt init*/

 HAL_NVIC_SetPriority(EXTI1_IRQn, 1, 0);

 HAL_NVIC_EnableIRQ(EXTI1_IRQn);

 HAL_NVIC_SetPriority(EXTI2_IRQn, 1, 0);

 HAL_NVIC_EnableIRQ(EXTI2_IRQn);

 HAL_NVIC_SetPriority(EXTI3_IRQn, 1, 0);

 HAL_NVIC_EnableIRQ(EXTI3_IRQn);

 HAL_NVIC_SetPriority(EXTI4_IRQn, 1, 0);

 HAL_NVIC_EnableIRQ(EXTI4_IRQn);

}

void EXTI4_IRQHandler(void)

{

   HAL_NVIC_DisableIRQ(EXTI4_IRQn);

   HAL_Delay(40);

   uint8_t a1=0;

   for ( uint8_t x1=0;x1<20;x1++)

   {

      a1+=(HAL_GPIO_ReadPin(in4_GPIO_Port,in4_Pin));

   }

   if ( a1> 12 )

   {

      ; rising edge

   }

   else if ( a1 < 8 )

   {

      ;// surely falling edge

   }

   else

   {

      ;

   }

 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);

   HAL_Delay(1000);

   HAL_NVIC_ClearPendingIRQ(EXTI4_IRQn);

   HAL_NVIC_EnableIRQ(EXTI4_IRQn);

}

extern void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

{

;

}

2 REPLIES 2

How would you make this determination?

You enable the interrupt as you leave, and the routine isn't going to re-enter.

Using HAL_Delay() inside an interrupt assumes the SysTick has a higher priority and will preempt.

Make your case with the output of a scope, or logic analyzer, of the input signal, vs a GPIO you drive high/low as you enter and exit the IRQHandler.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi Clive,

thank you for the reply.

using  HAL_NVIC_SetPriority(EXTI1_IRQn, 1, 0) i set SysTick priority higher than EXTI.

i do the input signal using and gpio changes within IRQHandler.

Regards, Ras