"setint": newbie question

Protolisk

Member
Hi I'm trying to use setint but its not working.

Code:
rapidon2:
setint %00001000,%00001000
Low 1
Pause 60000
High 1
interrupt:
If pin3 = 1 then pause3
setint %00001000,%00001000
goto rapidon2
pause3:
pause 10000
The interupt only seems to work once.
 

westaust55

Moderator
when an interrupt is detected, action/control transfers to a subroutine named interrupt.
Because it is a subroutine, a RETURN command is required to return to the main program (rapidon2: in your case)
Try this

Code:
init:
setint %00001000,%00001000  ; interrupt will occur when pin 3 goes high
rapidon2:
Low 1
Pause 60000
High 1
pause 10000
goto rapidon2
; end of the main code
;
; start of the Interrupt subroutine
interrupt:
;
; do what ever actions you need to here (when pin 3 is high)
;
setint %00001000,%00001000 ; establish interrupts before return to main program
return
 
Last edited:

Protolisk

Member
Ok thanks. Well your code works but whenever I try to modify it to work with mine it screws up.

What I want to do is have for the first rapid fire. A solid LED and when it shoots a flashing one. Then for the second rapid fire a flashing LED and when it fires a solid. Then for the burst or the last one I want a flash flash pause flash flash pause etc.

Right now the first mode is fine. Its just the second and third/burst.
Code:
Setfreq m8
rapidoff:
Low 1
do
if pin3 = 1 then pause1
loop while pin3 = 0
goto rapidoff
pause1:
pause 1000
goto rapidon
rapidon:
Low 1
High 1
Readadc 4,b0
If b0 > 80 then Rapidfire1
If pin3 = 1 then pause2
goto rapidon
Rapidfire1:
Do
High 1
High 4
Pause 120
Low 4
Low 1
Pause 115
b0=b0 and %00000000
Let dirs=b0
Readadc 4, b0
Loop while b0 > 80
goto rapidon
pause2:
pause 1000
goto rapidon2
rapidon2:
Low 1
High 1
Readadc 4,b0
If b0 > 80 then Rapidfire2
If pin3 = 1 then pause3
goto rapidon2
Rapidfire2:
Do
High 4
Pause 80
Low 4
Pause 75
b0=b0 and %00000000
Let dirs=b0
Readadc 4, b0
Loop while b0 > 80
goto rapidon2
pause3:
pause 1000
goto rapidon3
rapidon3:
Low 1
High 1
Readadc 4,b0
If b0 > 80 then Rapidfire3
If pin3 = 1 then pause4
goto rapidon3
pause4:
pause 1000
goto rapidoff
Rapidfire3:
Do
High 1
Low 4
Pause 80
High 4
Pause 80
Low 4
Pause 80
High 4
Pause 80
Low 4
Pause 80
High 4
Pause 80
Low 4
Pause 80
High 4
Pause 500
b0=b0 and %00000000
Let dirs=b0
Readadc 4, b0
Loop while b0 > 80
goto rapidon3
 

westaust55

Moderator
Can you explain a bit more about the code you uploaded.
Is it the main program or is it the interrupt portion?

For ALL newbies, it is good if you can format the layout of your program so that it is easy to read through - you will find if it is easier to read then others can understand it better and are more will ing to help you.

I have done that here but am not really sure what I am look at to help further. Can I suggest you upload your formatted complete program.
I also try and use a scheme for typing programs as follows:
1. Labels start with a capital (all other letters lower case) in the fist column
2. The rest of the program is indented by 8 or 10 spaces (not TABs) (see example below)
3. the inner part of loops FOR..NEXT, DO,.. WHILE etc are indented by a further 2 spaces to identify the loop structure better
4. variables all in lower case
5. all BASIC keywords/commands completely in CAPITALS

Code:
            Setfreq m8

rapidoff:   Low 1
            do
              if pin3 = 1 then pause1
            loop while pin3 = 0
            goto rapidoff

pause1:     pause 1000
            goto rapidon    ; this is unnecessary as it will automatically drop through to the label rapidon:

rapidon:    Low 1
            High 1
            Readadc 4,b0
            If b0 > 80 then Rapidfire1
            If pin3 = 1 then pause2
            goto rapidon

Rapidfire1: Do
            High 1
            High 4
            Pause 120
            Low 4
            Low 1
            Pause 115
            b0=b0 and %00000000
            Let dirs=b0
            Readadc 4, b0
            Loop while b0 > 80
            goto rapidon

pause2:     pause 1000
            goto rapidon2  ; this is unnecessary as it will automatically drop through to the label rapidon2:


rapidon2:   Low 1
            High 1
            Readadc 4,b0
            If b0 > 80 then Rapidfire2
            If pin3 = 1 then pause3
            goto rapidon2

Rapidfire2: Do
              High 4
              Pause 80
              Low 4
              Pause 75
              b0=b0 and %00000000
              Let dirs=b0
              Readadc 4, b0
            Loop while b0 > 80
   
            goto rapidon2

pause3:     pause 1000
            goto rapidon3  ; this line not necessary

rapidon3:   Low 1
            High 1
            Readadc 4,b0

            If b0 > 80 then Rapidfire3
            If pin3 = 1 then pause4
            goto rapidon3

pause4:     pause 1000
            goto rapidoff

Rapidfire3: Do 
              High 1
              Low 4
              Pause 80
              High 4
              Pause 80
              Low 4
              Pause 80
              High 4
              Pause 80
              Low 4
              Pause 80
              High 4
              Pause 80
              Low 4
              Pause 80
              High 4
              Pause 500
              b0=b0 and %00000000
              Let dirs=b0
              Readadc 4, b0
            
            Loop while b0 > 80
            
            goto rapidon3
 
Last edited:

hippy

Technical Support
Staff member
Another thing is to explain what's connected to what - what do High/Low 1 and High/Low 4 control ? What is read by READADC 4, and why is the value > 80 important ?

It also helps to say which PICAXE you're using.
 

westaust55

Moderator
Another thing is to explain what's connected to what - what do High/Low 1 and High/Low 4 control ? What is read by READADC 4, and why is the value > 80 important ?

It also helps to say which PICAXE you're using.

Very true Hippy.

I trolled thru some of Protolisk's past threads where he has been looking into 08M's and therefore guess that it is likely that is what is being used.



The rappidfire bit suggests one of those X-Box type mods which have previously been discussed on this forum (and I believe elsewhere).

Maybe we need a sticky for Newbies identifying more clearly what sort of information should be given in bullet point format. I know that there is already a sticky there making mention of some of the info that should be given. Maybe Rev_Ed can make it a post that msut be read and agreed to as part of taking up membership of this forum.
 
Top