|Use:||interrupt_clear( intpin )
|Description:||Clears the interrupt flag on a pin|
|Parameters:||intpin||Interrupt pin or circuit, this is a Pinname that has been used as an interrupt. The Pinname must be in the form Px_y. Where x is the port number, which can be 1 or 2, and y is the bit number which is between 0 and 7. (e.g. P2_3)
|Related:||eint(), dint(), interrupt_setup(), interrupt_disable()|
Use the interrupt_clear command to clear an interrupt so that it can be used again.
# The interrupt function flash_led is defined in the same way as any other mpy function def toggle_led(): # First operation is to clear the interrupt flag for P1_3, this allows new interrupts to occur interrupt_clear(P1_3) global x x = ~x # x is the on/off value for the Led , toggle its value out(P1_0,x) # Turn the LED on or off # Main code x = 0 # variable holding the LED state, set it off to start with dirout(P1_0) # set the REDLED pin as an output dirinpu(P1_3) # set the switch as an input with a pullup resistor interrupt_setup( P1_3, RISE, toggle_led) # setup a Rising pin interupt on P1_3, which will run the flash_led function eint() # Enable the global interrupt switch. No interrupts will happen until this has been set