Hardware Reference
In-Depth Information
This function attaches a function to the interrupt number interrupt , depending
on the status of the pin. The mode specii es the pin state to trigger the interrupt.
Valid states are LOW , CHANGE , RISING , FALLING , or HIGH . ISR names the function
you want to run. The ISR can be any function you write, but it cannot have
parameters and cannot return information.
The Arduino Due has a slightly different prototype, as shown here:
attachInterrupt(pin, ISR, mode) // Arduino Due only!
detachInterrupt()
This function detaches a previously attached interrupt handler from attachIn-
terrupt() . Interrupts on this ID will now be ignored. All other interrupts remain
in place. It requires the interrupt ID to function.
detachInterrupt(interrupt);
This function is again slightly different for the Arduino Due; the Due requires
the pin number to be specii ed, not the interrupt ID.
detachInterrupt(pin); // Arduino Due only!
noInterrupts()
noInterrupts() temporarily disables interrupt handling. This is useful when
you are in an interrupt handler and do not want to be disturbed by other inter-
rupts. It does have a down side; some system functions require interrupts,
mainly communication. Do not disable all interrupts just because your code
does not require user-made interrupt handlers. Disable interrupts only when
there is timing-critical code being performed.
// Normal code
noInterrupts();
// Time critical code
interrupts();
// Normal code
interrupts()
interrupts() re-enables all interrupts. You do not need to reconi gure inter-
rupt handlers; all interrupts will be reconi gured as they were before calling
noInterrupts() .
 
Search WWH ::




Custom Search