INTERRUPT
 
Syntax

INTERRUPT ( expression)
Description


INTERRUPT will disable interrupts if expression is 0.  And it will enable interrupts if expression is non-zero.  The default case is to have interrupts enabled.

Use this routine with caution, such as generating fixed time signals, or doing synchronous input.  Do NOT disable interrupts around large sections of the program.  Serial input will stop functioning and characters may be lost if interrupts are off for too long.

On the Cortex parts with firmware after 8.28, if interrupts are off, the TIMER will not update the upper 16 bits (meaning it can't count beyond 65 microseconds).  For timing with interrupts off, use WAIT_MICRO instead.  Or you can turn on just the interrupt used by TIMER with --

INTERRUPT(0)
ST_CTRL OR= 2   ' enable the SysTick interrupt

Example

' read a synchronous byte from a device with ready on pin 0, clock pin 1 and data on pin 2

FUNCTION ReadBit
  WHILE IN(1)=0 ' wait for clock to go high 
  LOOP
 RETURN IN(2) AND 1
END FUNCTION

 '...

WHILE IN(0) ' wait for ready signal
LOOP

INTERRUPT (0)
BIT0 = ReadBit
BIT1 = ReadBit
BIT2 = ReadBit
BIT3 = ReadBit
BIT4 = ReadBit
BIT5 = ReadBit
BIT6 = ReadBit
BIT7 = ReadBit
INTERRUPT (1)

VALUE = BIT0 + (BIT1<<1) + (BIT2<<2)+ (BIT3<<3)+ (BIT4<<4)+(BIT5<<5)+ (BIT6<<6)+ (BIT7<<7)
Differences from other BASICs

See also