Hardware interrupt confusion

Brian Z

New Member
I am trying to keep a Picaxe in sleep until it gets an interrupt pulse on a pin, but I'm having some confusion understanding the process. I understand that I need a hintsetup command to get things set up, and since I'm using a 20x2, I'm going to use a %01000100 mask to use inturupt 1 on a rising edge. The manual then says that I must use setintflags to generate an interupt, but when I read up on it, I can't figure it out. I gather I need a
Code:
setintflags: %00000010,%00000010
, but what pin is INT1 tied to? How does setint play into all of this?

Thanks for any help on this!

Brian Z
 

hippy

Technical Support
Staff member
The HINT1 pin on a 20X2 is pin B.0. That can be shown as such using the "Input/Output Table" link under the PICAXE selection in the Workspace Explorer panel of PE6.

When using HINT interrupts, you need to use HINTSETUP then SETINTFLAGS. The SETINT command is not used in this case as it provides for an alternative means of interrupt.

To configure HINT1 as a rising edge -

HIntSetup %00100010

To interrupt on HINT1 activated -

SetIntFlags %00000010, %00000010

An example program which runs in the PE6 simulator is -

Code:
#Picaxe 20X2

HIntSetup %00100010
SetIntFlags %00000010, %00000010

Do
  Pause 10
Loop

Interrupt:
  SerTxd( "Interrupted" )
  hInt1Flag = 0
  SetIntFlags %00000010, %00000010
  Return
 
Top