Help with setint/interupt

Well when I was having.the problem with a switch not reacting fast enough ive dicovered the interupt command sequence and was wondering if somoene could give me a simple example using it. Say
With 20m2 chip a button and one led. I would appreciate it.as the syntax example would help. Confused on the way I designate the 8 bit to pin %00000000,%00000001
 

ac21

Member
Code:
[color=Navy]#picaxe [/color][color=Black]20m2[/color]
[color=Navy]#no_data[/color]

[color=Blue]symbol [/color][color=Black]LED [/color][color=DarkCyan]= [/color][color=Blue]b.6


setint [/color][color=Navy]%00001000[/color][color=Black],[/color][color=Navy]%00001000 [/color][color=Green]; high on c.3 will interrupt[/color]

[color=Black]main:
   [/color][color=Blue]do   
                
      for [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]to [/color][color=Purple]b1
            [/color][color=Blue]high [/color][color=Black]led 
            [/color][color=Blue]pause [/color][color=Navy]100
            [/color][color=Blue]low [/color][color=Black]led
            [/color][color=Blue]pause [/color][color=Navy]100       [/color][color=Green]; program running waiting for interrupt between do/loop 
      [/color][color=Blue]next
            pause [/color][color=Navy]700   
   [/color][color=Blue]loop



interrupt:

       
      if [/color][color=Purple]pin3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then [/color][color=Black]interrupt   [/color][color=Green]; loop here until button is released 
      [/color][color=Blue]pause [/color][color=Navy]20                       [/color][color=Green]; Debounce button
      [/color][color=Blue]inc [/color][color=Purple]b1
      [/color][color=Blue]setint [/color][color=Navy]%00001000[/color][color=Black],[/color][color=Navy]%00001000
      [/color][color=Blue]return[/color]
 
Ive read.it. over and.over. heres.the.thing. theres eight 00000000
But theres 20 pins. 8 in out on right. 8 in out on left. How do I designate pins the command line is %pins in use,pin your looking for and pin state. %00000000,00000000
 

AllyCat

Senior Member
Hi,

Interrupts are only available on (up to) the 8 input pins of one port.

The "bit mask" concept may not be easy, but unless you tell us exactly which pin(s) you are using, and whether the signals are active high or active low, then we can't tell you what's needed (or whether it can work).

Cheers, Alan.
 

ac21

Member
On a 20m2 only pins c.0 to c.5 can be used.
Pin c.0 is %00000001
Pin c.1 is %00000010
its all in the manual plus the editor will let you know if you try to use something else.
 
Top