Strange SETINT behaviour

dgc188

New Member
I'm wanting to have the option of changing the mask for a SETINT command depending on a test of variables but I keep getting a syntax error. I'm using a 28X2 on the AXE201. PE 6.1.0.0, compiler v.3.4.

In the main body of the code I use:
main:
setint OR %00000011, %00000011
to independently monitor two inputs, and in the interrupt: subroutine I then use:
interrupt:
sens7=pinC.0
sens8=pinC.1
if sens7wkg=0 then : sens7wkg=sens7 : endif
if sens8wkg=0 then : sens8wkg=sens8 : endif
if sens8wkg=1 then : setint %00000001, %00000001 : endif

which will be pointed back to main: after the return command (and the above SETINT command) and the syntax is happy despite a difference in the active commands in the interrupt: and main: routines. :)

However - if I want to put differing SETINT masks within IF...THEN commands so that if one variable has gone 'active' I can still monitor the other port while its variable is 'inactive' and ignore the still 'active' port, I get the syntax error: :(
if sens8wkg=1 then : setint %00000001, %00000001 : endif - this and the next line should monitor one port or the other depending on its specific variable
if sens7wkg=1 then : setint %00000010 %00000010 : endif
if sens7wkg=0 and sens8wkg=0 then : setint OR %00000011 %00000011 : endif
- which monitors both ports (effectively the same as the command after main: )

Even if I put the three IF...THEN commands after main: (in place of the original command and not in the interrupt: routine) I still get the syntax error on them.

If only one SETINT command can be active depending on the variables sens8wkg and sens7wkg why does it not allow the above section of the interrupt: (or main: ) routine and yet accept differing SETINT commands as described earlier?

Baffled! 🥴 What am I doing wrong, or misunderstanding?
 

inglewoodpete

Senior Member
I'm wanting to have the option of changing the mask for a SETINT command depending on a test of variables but I keep getting a syntax error. I'm using a 28X2 on the AXE201. PE 6.1.0.0, compiler v.3.4.

In the main body of the code I use:
main:
setint OR %00000011, %00000011
to independently monitor two inputs, and in the interrupt: subroutine I then use:
interrupt:
sens7=pinC.0
sens8=pinC.1
if sens7wkg=0 then : sens7wkg=sens7 : endif
if sens8wkg=0 then : sens8wkg=sens8 : endif
if sens8wkg=1 then : setint %00000001, %00000001 : endif

which will be pointed back to main: after the return command (and the above SETINT command) and the syntax is happy despite a difference in the active commands in the interrupt: and main: routines. :)

However - if I want to put differing SETINT masks within IF...THEN commands so that if one variable has gone 'active' I can still monitor the other port while its variable is 'inactive' and ignore the still 'active' port, I get the syntax error: :(
if sens8wkg=1 then : setint %00000001, %00000001 : endif - this and the next line should monitor one port or the other depending on its specific variable
if sens7wkg=1 then : setint %00000010 %00000010 : endif
if sens7wkg=0 and sens8wkg=0 then : setint OR %00000011 %00000011 : endif
- which monitors both ports (effectively the same as the command after main: )

Even if I put the three IF...THEN commands after main: (in place of the original command and not in the interrupt: routine) I still get the syntax error on them.

If only one SETINT command can be active depending on the variables sens8wkg and sens7wkg why does it not allow the above section of the interrupt: (or main: ) routine and yet accept differing SETINT commands as described earlier?

Baffled! 🥴 What am I doing wrong, or misunderstanding?
It is difficult to diagnose your problem without more of your code. As shown at the moment there is no main loop: execution would immediately execute the interrupt routine after initialising the interrupts. The interrupt routine should be structured like a subroutine, ending with a return statement.

Have you posted all of your code (that demonstrates the problem) or have you cut bits from your program, which makes it impossible for members to fully understand or test?

Edit: I cut your code out of your post and, after adding several symbol statements and do, loop and return commands, the syntax of the last two setint commands was missing a separator between the setint's parameters.
 
Last edited:

dgc188

New Member
Thanks inglewoodpete for the comments. Not all the code was copied over to my post - the main: routine was very severely truncated (mostly to save space) and without the obligatory 'goto main' shown prior to the interrupt: routine - it was there in my code, just not copied over to here. The full code took the basic form of:
(symbol settings)
main:
(code blah blah blah code)
goto main
interrupt:
(etc as quoted above)
return

Looking over your comments and checking back at my code I can see where things have gone wrong - all my mistake. I thought I'd written/coded it up correctly. I can now see, as you pointed out, that there were a couple of comma separators missing from two of the SETINT lines. I've put them in where they ought to be and all is now happy; no syntax errors. I guess this is what happens when trying to type code while there are distractions going on. And the manual didn't help by stating that "Only one input pattern is allowed at any time." and that confused me into thinking literally only one input pattern, not effectively three of them as I was trying.

The position of the IF...THEN SETINT commands will probably need to be taken out of the interrupt: routine and put into the main: body of the code or else I've achieved nothing by still being in a loop within the interrupt: routine. Something to work on.

I spent ages going round and round in circles moving the commands around thinking the positioning was critical, each time copying/pasting the error (with the missing commas) and not being able to figure out what was wrong. The syntax error also being not over-helpful in pointing to what was wrong. Had it pointed to where the missing comma was (or wasn't) it would have been more obvious and found quicker instead it pointed to the end of the command, not the centre where the error was.

So, apologies to all who read the post. As usual, it's all down to me (it usually is) and my overlooking the blatantly obvious. Thanks again for the pointer to the error of my ways. Next time I'll pay closer attention to what I'm typing (and not take the manual - or the syntax error pointer position - quite so literally).

Thanks again.
 
Last edited:

hippy

Senior Member
It would be worth posting your full code, at least the full interrupt routine, because there appears to be an issue where it the interrupt may activate a couple of times then stop working, but it's hard to tell without knowing what you are attempting to achieve.
 

dgc188

New Member
Thanks hippy, but having resolved the issue of the entering and receiving the 'strange SETINT behaviour' (syntax error) all due to my typo mistake and lack of thorough enough checking for that typing (by not noticing the missing comma separator in the SETINT commands), I think the problem has effectively been resolved.

As noted above, the revised IF....THEN SETINT commands are now parsed correctly and once a bit more code has been written, I have every faith the program will work as envisioned. At the time I just couldn't understand why I was getting the syntax error. All is now clear.

Thanks again to all for pointing out the error of my ways. I consider myself (self-)reprimanded for not sufficiently checking my own typing.
 

lbenson

Senior Member
I consider myself (self-)reprimanded for not sufficiently checking my own typing.
Sometimes it can be hard to spot what one has done wrong, especially if one is incorrectly focusing on something other than punctuation. I suspect we've all been there--I know I have many times.
 
Top