Don't have a 16F688 to test, but this works in MPSIM --
Code:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
DEFINE OSC 4
OSCCON = %01100000 ' 4MHz internal
ANSEL = 0 ' Set portA outputs to Digital / No ADC
CMCON0 = 7 ' comparators disabled
PORTA = 0
TRISA = %00000001 ' RA0 input
OPTION_REG.7 = 0 ' pull-up global enable
WPUA = %00000001 ' pull-up enabled on RA0
include "DT_INTS-14.bas"
include "ReEnterPBP.bas"
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RAC_INT, _MyInt, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE RAC_INT ; Enable RA change interrupt
ENDASM
WHILE !PORTA.0 ' read for wake up om change
WEND
IOCA.0=1 ' RA0 int-on-change enabled
Main:
TOGGLE PORTA.2
PAUSE 500
GOTO Main
MyInt:
WHILE !PORTA.0
WEND ' wait for button release
TOGGLE PORTA.1
@ INT_RETURN
Just added these to DT_INTS-14 --
Code:
#define RAC_INT INTCON,RAIF ;-- RA Port Change Interrupt
ifdef RAIF ;----{ RA Port Change Interrupt }--------------[INTCON, RAIF]---
INT_Source INTCON, RAIF, INTCON, RAIE
endif
Bookmarks