12.07.2015 Views

PICAXE Manual Section 1 - TechnoPujades - Free

PICAXE Manual Section 1 - TechnoPujades - Free

PICAXE Manual Section 1 - TechnoPujades - Free

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.picaxe.co.uk<strong>Section</strong> 1 70GETTING STARTEDTutorial 11 - Using InterruptsAn interrupt is a special case of a sub-procedure. The sub-procedure immediatelyoccurs when a particular input (or combination of inputs) is activated.A polled interrupt is a quicker way of reacting to a particular input combination.It is the only type of interrupt available in the <strong>PICAXE</strong> system. The inputs port ischecked between execution of each command line in the program, between eachnote of a tune command, and continuously during any pause command. If theparticular inputs condition is true, a ‘gosub’ to the interrupt sub-procedure isexecuted immediately. When the sub-procedure has been carried out, programexecution continues from the main program.The interrupt inputs condition is any pattern of ‘0’s and ‘1’s on the input port,masked by the byte ‘mask’. Therefore any bits masked by a ‘0’ in byte mask will beignored.e.g.to interrupt on input1 high onlysetint %00000010,%00000010to interrupt on input1 low onlysetint %00000000,%00000010to interrupt on input0 high, input1 high and input 2 lowsetint %00000011,%00000111etc.Only one input pattern is allowed at any time. To disable the interrupt execute aSETINT command with the value 0 as the mask byte.Notes:1) Every program which uses the SETINT command must have a correspondinginterrupt: sub-procedure (terminated with a return command) at the bottomof the program.2) When the interrupt occurs, the interrupt is permanently disabled. Therefore tore-enable the interrupt (if desired) a SETINT command must be used withinthe interrupt: sub-procedure itself. The interrupt will not be enabled until the‘return’ command is executed.3) If the interrupt is re-enabled and the interrupt condition is not cleared withinthe sub-procedure, a second interrupt may occur immediately upon the returncommand.4) After the interrupt code has executed, program execution continues at thenext program line in the main program. In the case of the interrupted pause,wait, play or tune command, any remaining time delay is ignored and theprogram continues with the next program line.revolution(c) Revolution Education Ltd. Email: info@rev-ed.co.uk Web: www.rev-ed.co.ukVersion 6.9 07/2009All rights reserved.70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!