Hi Tabsoft, I got the comparator working perfectly so I decided to move onto adding an interrupt, which believe it or not hasn't worked. Here is the code I have fully written, maybe you can help where I have gone wrong?

Thanks,
Rob

You will probably have a laugh at this, as its probably completely wrong lol


Code:
'PIC 12F683

#CONFIG 
   __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
#ENDCONFIG

PAUSE 20 'wait for hardware to settle

DEFINE OSC 4 '4mhz ocsillator
ANSEL = %00000010 'pin 6 analog
CMCON0 = %00000100 'comparator mode
VRCON = %10101000 'voltage reference
TRISIO = %00000010 'pin 6 input

ON INTERRUPT GOTO SLSELECT 'interrupt handler is slselect
INTCON = %11001000 'enable GIE and GPIE; clear GPIF
IOC = %00000010 ' enable IOC1 (GPIO.1 Interrupt on change)
PIE1 = %00001000 'enable comparator interrupt

POT1 VAR CMCON0.6 'read potentiometer
LED VAR GPIO.2 'led pin 5

ENABLE
main:
HIGH LED 'light led
GOTO main 'repeat

DISABLE 'disable interrupts in handler
SLSELECT:
IF POT1 = 1 THEN 'if <1.1v sleep
NAP 1
ELSE
ENDIF

INTCON = %10001000  'enable GIE and GPIE; clear GPIF
PIR1 = %00000000 'reset CMIF
RESUME 'where left off
ENABLE 'enable interrupts