10 years, 10 months ago.

__disable_irq()

Hi guys, I am working on my code which uses many different serial communication receiving interrupts. I am using disable_irq() to disable the interrupts when required and then enabling it.

My question is does it disable all the receiving interrupts running at the moment. If yes how can I disable specific interrupts.

Regards Kamil

3 Answers

10 years ago.

Here you go

IRQ Demo

#include "mbed.h"

DigitalOut myled(LED1);
DigitalOut myled2(LED2);

InterruptIn MyIRQ(p21);

void LED_on_off_IRQ(void)
{    
    myled=!myled;  // LED1 goes on or off every time p21 goes high.
} 


int main() {
      
while(1){
    
    myled2=1;
    
    MyIRQ.rise(LED_on_off_IRQ); // calls LED_on_off_IRQ when p21 goes high
    
    wait(5);
    
    myled2=0;
    
    MyIRQ.rise(NULL);  // stops the IRQ can't change LED1 state    

    wait(5);
 
 }

}

Accepted Answer

Thank you. Quite nice and simple example :)

posted by Amreen Ahmed 22 Mar 2014
10 years, 10 months ago.

NVIC_DisableIRQ(UART0_IRQn) is probably the function you search.

Depending on your requirements you can also attach a NULL pointer with the mbed attach function (in case there is no detach function).

Thank you :)

posted by Amreen Ahmed 12 May 2013
10 years ago.

hi, can you give me an example of disable the interrupts when required and then enabling it.

please i have problems