External Links

Creative Science Centre

 

Library_interrupts

// #include "http://www.byvac.com//mBlib/flb/Library/2016/lib_intr.bas"

INTERRUPTS

Currently defined interrupts are for the ports (interrupt on change) and the timers. The necessary attributes to make these work are either in the PORTx contants or TIMERnn contants.

The following will clear all of the interrupts and remove then from the interrupt table.

ir_clear()

An interrupt will call a user function and so setting up an interrupt involves selecting why an interrupt occurs (timer, external etc.) and then pointing this to a user function that will be called when the interrupt happens.

ir_di()

Globally enables interrupts, this is only needed after the use of ir_di() as the interrupts are normally enabled.

ir_ei()

There is another type of interrupt 'set' that applies to interrupt on change. The interrupt in this case is different for MX1 and MX3 devices.

Timing

There is a delay between the interrupt happening and the function being called, this is approximately 0.5ms and so if the timing required is less than this a plug in will be required.

Tip

When working with interrupts, particularly those that work with a timer. the interrupt will be active all of the time or at least after the user program has run. This will effect the download process and so the interrupt should be stopped for that, one way to do this is to reset the device before downloading but it is easy to forget to do so. The simplest way is to put ir_clear() in the send string ot the tload dialog box like this:


(dialog box from the .tl command of BvSerial)