11 years ago.

interrupt disable

Hi all, I was using interrupt method to generate different interrupts on port A and port D, I could enable and disable the interrupts as well by calling disable_irq(); and enable_irq(); , Issue was The interrupt method is very sensitive to inputs and it has the debouncing issue as well, So I shifted to PinDetect method. Now it is very stable, but I am not able to disable and enable the interrupts here. Please help me

Kind Regards, Zain

1 Answer

11 years ago.

PinDetect works different than InterruptIn, option one which probably should work is attach a NULL pointer. In general mbed callbacks aren't called when you attach NULL. However the nice way a library handles this is by also disabling the generation of the interrupt behind it. While PinDetect would still continue to operate and consume resources in the background, which you might prefer it wouldn't do.

In that case besides attaching the NULL pointer, is use the setSampleFrequency function and put it on a stupidly high period (function says frequency, means period). So effectively the underlying ticker code is (almost) never called. When you want to use it you would need to set your interrupt again, and if you also changed the SampleFrequency you also need to set that correct again (calling the function with no arguments will do that).

Thanks for your detailed answer, I tried another approach and it worked for me as well. I set a variable global flag a=1, and when I call the interrupt I set this variable to a=0; inside a function so that no other function can access it. Simple if commands :)

posted by zain aftab 15 Aug 2014