using interrupts in different slots

jinx

Senior Member
hi,
i just had quick test using using the duck bumpers as a program select in the first slot that worked but in slot 2 using the interrupt on b.0,b.1,b.2 as the bumper does'nt work can I not use the interrupts between slots?
 

jinx

Senior Member
thx nick i have that i got it working like this : in the first slot I use the interrupt to move to slot2 without resetting the interrupts, So i added this line to the start of slot 2
init:SetIntFlags %00001000, %00001000 and all is fine

ps good morning nick
 

jinx

Senior Member
Would someone please look over my interrupt setup i think it right it works as expected but some times my code can work by chance/luck

Code:
#picaxe 28x2
#no_data
#no_table




pullup %00000111 		      	
hintsetup %0000111 			'set INT1 and INT2 to trigger Interrupt at falling edge
setintflags %00001000,%00001000  	'enable interrupt flags
setint %00000000,%01110000,b       

init:servo pan,cen
     servo tilt,tcen
     servo r, r_off
     servo l, l_off
     pause 30
       
  pause 100
    
 main:
	
                                        ' floor led
          do
          	servopos tilt,Tcen              'panning servo for effect
          for counter = 1 to 3
            for b1 =lft to rgt step 2
            servopos pan,b1
           pause 20
       next b1
       
       for b1 =rgt to lft step -2
       servopos pan,b1
       pause 20
      
    
	next b1 
	next counter
	servopos pan,cen
	pause 20
	servopos tilt,T_dwn 
	pause 20
     sleep 10 
    loop
 



Interrupt:
  	 
  	hintflag = 0 			      	'rest hintflags to 0
  	If hint1flag = 1 Then 		      	'check to see if INT1 has bee triggered
    	    	
    	      run 2	
    		hint1flag = 0		      	'reset hint1flag to 0
  	End If
  		If hint2flag = 1 Then               	'check to see if INT2 has bee triggered
    		
    	     run 3
    		hint2flag = 0
  	End If
  	
      	SetIntFlags %00001000, %00001000        	'renable hint interrupts
  	return
 

inglewoodpete

Senior Member
All a bit muddled, I'm afraid. Most of the stuff I've written here should be in the manuals but can be hard to find.

SetInt and SetIntFlags are mutually exclusive configurations. I suggest you leave out the "setint %00000000,%01110000,b" command and just used the hardware interrupts.

Run commands (Eg Run 2) mean "GoTo Slot x and never return". So any code underneath the Run x command can never execute. The subroutine "stack" is also reset.

Any timers etc and (I understand) all flags are reset when execution starts in a new slot. So no need to clear them.

Registers b0-b55 (w0-w27) and the user RAM and scratchpad are preserved.
 
Top