28x2 and hintsetup ...what am I doing wrong?

kevrus

New Member
After migrating a working program from a 28x1 to a 28x2, I noticed an interrupt issue.
In a nutshell, I can't seem to get out of the interrupt routine...here's a test routine thats using INT 0 (B.0). It goes to interrupt when B.0 = 1, but keeps jumping back into the interrupt routine when B.0=0. Ive tried various combos of hintsetup and also issued a setinflags off
before the re-issue of the setinflags..this is in the sim and the 28x2 chip

Must be me but I can't see what i'm missing...

Code:
Hintsetup %00001001  'SETS INTERRUPT


main:
setintflags %00000001,%00000001 

do
pause 2000
loop


interrupt:

if pinB.0=1 then interrupt     'loop until switch is released

for b1=0 to 5
high A.0
pause 1000
low A.0
pause 1000
next b1
setintflags %00000001,%00000001
return
 

hippy

Technical Support
Staff member
Once the activation is detected on B.0 it sets 'hint0flag' which then causes the interrupt when SETINTFLAGS handling polls things. Unless you clear that flag the interrupt will occur again. Add this to the end of your interrupt routine ...

hint0flag = 0

The 'hint0flag' will only activate as edge triggered so it isn't necessary to check that B.0 has gone low again within the interupt.
 

kevrus

New Member
Thanks Hippy, that works great on my test code...ive still got the same issue on my 'real' program so ive done something else wrong and the interrupt may not be the issue after all...a bit more studying I think
 

BeanieBots

Moderator
I had a lot of fun with this too.
Depending on your code, you might want (need) to clear the individual flags as well.
Also, the 28X2 hardware interrupts are blindingly fast. Despite them being edge triggered, I was getting multiple trips at both set AND release of the buttons. It took a while to realise that this was because of contact bounce which had never been a problem for me before.
A 10k/22nF between switch and input cured the problem.
 

kevrus

New Member
BB, I think you may be right about the switch bounce...I did try numerous 'flag' resettings but now reverted back to the 28x1 as this works fine, but will keep that in mind though when I try the x2 again.

I only tried the x2 on this project for ease of PCB layout due to the configurable pins...
 

BeanieBots

Moderator
This worked for me. (three push to make high buttons on the hardware int pins)

Start:
hintsetup %01110111 ‘ enable all 3 pins (trigger when pushed)
setintflags %00001000,%00001000 'Interrupt if ANY button is pushed

main:
Code here that checks for the other flags and does whatever.
Remember to clear the flags (0,1 & 2) after the action.
goto main

Interrupt:
pulsout PIEZO,100 'make a little click for each key-press.
flag3=0'clear the interrupt flag
setintflags %00001000,%00001000
Return

It essentially works like a polled interrupt but the user only needs a brief push for it to be registered rather than having to hold down the button until the 'polling' software gets around to checking the status.

Until I added the 10k/22nF it would register a press on both push AND release.
This was mainly due to the poor design of my illuminated buttons but even one of the tactile buttons on the AXE091 would sometimes give a double trigger without any 'slugging' applied to it.
 
Top