Ok, I've spent a good couple of hours trying to revise hos the whole DT interupt fits together (I never really got it the first time, still haven't but hey - the world loves a trier!)
Ok, I have my interupt working - of a sort. By this I mean my program reacts to the button I have wired to the 'INT' EXT interupt pin on my 16F690 (pin 17) ...but my program only responds to the associated button being pressed the once?!
No matter how many times (Or for how long I hold down) I press the button connected to th4e INT pin - I don't get anymore interupts.
I'm puzzled.
My program is a little unwieldly (so is my programming!), but here (I think!) are the relevant extracts..
Code:
@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
@MyConfig = MyConfig & _MCLRE_OFF & _BOR_OFF
@ __config MyConfig
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts
OSCCON = %01100000 ' 4MHz internal osc
ANSEL = %11000000 ' AN2 &AN7 = Analogue (for AtoD), the rest digital
ANSELH = 0
ADCON0 = %10001001 ' Right justify, channel AN2, A/D enabled
CM1CON0 = 0
CM2CON0 = 0
VRCON = %00000000 ' turns the Vref Module OFF by CLEARING bit7, 6, 4
INTCON.0 = 0 ' clears the RABIF Flag (to 0), COULD be 1 on reset (unique to F690)
RCSTA.7 = 0 ' clears the SPEN bit ( SETTING SPEN DISABLES RB7 AS GENERAL PURPOSE! )
OPTION_REG.6 = 0 ' this allows interupts on falling edge (high to low transitions)
TRISA = %00000100 ' RA2 input, rest out
TRISC = %00001100 ' RC3, RC4 inputs, rest outputs
sustainer_state VAR BYTE
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _OnOff_Switch, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE INT_INT ; enable external (INT) interrupts
sustainer_state = 0
Sustainer_on:
(my program does stuff here - not relevant to the question I'm posing!)
Sustainer_off:
Pause 500
Goto sustainer_off ' just keep looping until we get another interupt
'---[INT - interrupt handler]---------------------------------------------------
OnOff_Switch:
sustainer_state = sustainer_state +1
IF sustainer_state = 1 then GOTO sustainer_on
if sustainer_state !=1 then
SUSTAINER_STATE = 0
goto sustainer_off
endif
@ INT_RETURN
Any top tips greatfully received?
or even a more elegant way of trying to crack this meagre nut! I just want a simple push button interupt to stop my program (& just loop) until the next 'interupt (button press) comes in.
Bookmarks