I would probably skip the interrupt and perform everything in a tight loop instead. As the Relay check is done pretty quick. Not a fan of using GOSUBs in a ISR.
From what i feel, S2 should have dual contacts attach to GPIO<1:0>
To know which relay is activated, i would bet that...
Code:
WhichRelay VAR BYTE
'
'
'
'
WhichRelay=GPIO & 3
Select case WhichRelay
CASE 0 ' Relay 2
' do stuff for relay 2
CASE 1 ' Relay 1
' do stuff for relay 1
CASE 2 ' Relay 3
' do stuff for relay 3
END SELECT
If you still want to use Ints, don't re-enable the GIE bit, the PIC will do it for you. Just clear the offending INT flag and get out of there.
If you play with GIE bit, you will run into problems, that's for sure.
Last edited by mister_e; - 27th May 2008 at 16:34.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks