cancel
Showing results for 
Search instead for 
Did you mean: 

Disable nterrupt inside the IRQ Handler allowed??

Jannaros
Associate II

Hello,

i disable the interuppt after its execution is it allowed?

void EXTI4_IRQHandler(void)
{
  // Clear interrupt
  __HAL_GPIO_EXTI_CLEAR_IT(SYNC_UC_PIN);
 
   // call function
   function();// the function enables an other interrupt of the same priority
   HAL_NVIC_DisableIRQ(EXTI4_IRQn);//disable the interrupt trigger SYNC_UC_PIN
}
 

 after that i enable it after 200 millisecconds:

                                //activate flash interrupt
                                while (HAL_NVIC_GetPendingIRQ(EXTI4_IRQn))//clear interrupt pending bits
                                {
                                    __HAL_GPIO_EXTI_CLEAR_IT(SYNC_UC_PIN);
                                    HAL_NVIC_ClearPendingIRQ(EXTI4_IRQn);
                                }

7 REPLIES 7

Yes.

You will need an EnableIRQ() function to enable it, the ClearPendingIRQ() is something different.

JW

PS. Please change your username to a normal nick.

Jannaros
Associate II

Hi changed the name.

Yes after deleting the pendig bit i enable it.  

  HAL_NVIC_EnableIRQ(EXTI4_IRQn); //enable interrupt for triggern

But i tryed to modify the interrupt Handler and i place the disable interrupt before the function()

then the sofware does not work properly.

void EXTI4_IRQHandler(void)
{
  // Clear interrupt
  __HAL_GPIO_EXTI_CLEAR_IT(SYNC_UC_PIN);
   HAL_NVIC_DisableIRQ(EXTI4_IRQn);//disable the interrupt trigger SYNC_UC_PIN
   // call function
   function();// the function enables an other interrupt of the same priority
 
}

What do you mean by "does not work properly"?

The other interrupt of the same priority will not be called until you exit this interrupt.

JW

Jannaros
Associate II

When i trigger the SYNC_UC_PIN in the seccond case, with the disabling interrupt at first place in handler.

Then the other interrupt enabling in the function does not occurs .

void function(void)
{
..
HAL_NVIC_EnableIRQ(ADC_IRQn);
..
}

The SYNC_UC_PIN triggers on its own again even if it is dissabled when an new signal SYNC_UC_PIN comes.

I don't understand.

Maybe prepare a minimal but complete compilable example exhibiting the problem.

JW

Jannaros
Associate II

Hi,

If my system is ready i enable the interrupt EXTI4_IRQn . I trigger this interrupt EXTI4_IRQn in worst case every 300Hz and it comes through only when the system is ready, that means Enable HAL_NVIC_EnableIRQ(EXTI4_IRQn). As the interrupt happens in the irqhandler i disable it because my system will not be ready enymore and i start an analog digital converter mesurement ADC_IRQn. The ADC_IRQ is programmed as an watchdog and when the system reaches a state it triggers.

When i disable the EXTI4_IRQn before i call the function() then it seems that the ADC_IRQn does not mesure and the EXTI4_IRQn cause interrupt sometimes later on its on even if its dissabled.

thanks

Jannaros
Associate II

Hi Can i Put the __DSB(); function after the disabling of EXTI4_IRQn in interupt handler ?