cancel
Showing results for 
Search instead for 
Did you mean: 

DISABLE/ENABLE EXTI interrupts using hal

seed
Associate III
Posted on November 10, 2015 at 15:39

Hi,

I need to disable a EXTI interrupt and then enabling it again later. How can I do that using the hal implementation? I am working on STM32F070.
4 REPLIES 4
ftiti
Associate II
Posted on November 11, 2015 at 15:17

You should use the Interrupt & Flag management macros existed in each peripheral .h file .

For example to manage DMA interrupts :

__HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__);

__HAL_DMA_EDISABLE_IT(__HANDLE__, __INTERRUPT__);

or TIM interrupts: 

 __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__);

 __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__);

CIAO

seed
Associate III
Posted on November 11, 2015 at 16:30

Hi,

The EXTI does not work the same way since it share interrupt handler with other gpio pins. I have no handle to use. See code below.

Call stack - EXTI4_15_IRQHandler - HAL_GPIO_EXTI_IRQHandler - HAL_GPIO_EXTI_Callback.

I want to disable interrupt on GPIO_PIN_11 for a while, how do I do that? Or should I change the gpio mode?

I can't find something like __HAL_GPIO_EXTI_DISABLE_IT(GPIO_Pin)..

Gpio_Init(void)

{

 GPIO_InitTypeDef GPIO_InitStruct;

 

...

  __GPIOC_CLK_ENABLE();

  /*Configure GPIO pin : PC11 */

  GPIO_InitStruct.Pin = GPIO_PIN_11;

  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;

  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct)

 

    /* EXTI interrupt init*/

  HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);

  HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);

}  

 

stm32f0xx_it.c

/**

* @brief This function handles EXTI line 4 to 15 interrupts.

*/

void EXTI4_15_IRQHandler(void)

{

  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_11);

}

stm32f0xx_hal_gpio.c

/**

  * @brief  Handle EXTI interrupt request.

  * @param  GPIO_Pin: Specifies the port pin connected to corresponding EXTI line.

  * @retval None

  */

void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)

{

  /* EXTI line interrupt detected */

  if(__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)

  {

    __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);

    HAL_GPIO_EXTI_Callback(GPIO_Pin);

  }

}

main.c

/**

  * @brief EXTI line detection callbacks

  * @param GPIO_Pin: Specifies the pins connected EXTI line

  * @retval None

  */

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

{

  if (GPIO_Pin == GPIO_PIN_11)

  {

    /* OK */

  }

}

arik
Associate
Posted on February 02, 2016 at 16:19

Hi,

Did you found a solution for that?

How about disabling the IRQ with HAL_NVIC_DisableIRQ(EXTI4_15_IRQn) and then enabling it again when ever needed, of course it will disable all EXTI from 4 to 15 but it might help in your case.

ABans.3
Associate II

You could use something like, on test port and test pin:

 

HAL_GPIO_DeInit(test_GPIO_Port,test_Pin);
// disable the interuupt
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = test_Pin;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(test_GPIO_Port, &GPIO_InitStruct); // initialize it again
 
This will disable the interrupt  on that pin. 
 
Thanks