Thanks for suggestion. I am stuggling rather with the pseudo code but have found some code in another post and copied it with just one modification i.e.the line ansel = 0 in the original code would not compile so I have used cmcon = 7 instead (to set port a to digital). The program runs and goes to sleepok but refuses to wake up when ra2 goes high. If I switch wdt on I notice that the pic wakes itself up after a second or so. I have trawled the forum and the web to find out why without any success at all. I'm sure I must be doing something dumb (an increasingly common occurence !) The code I am using is as follows:
[@ DEVICE pic16f628a,intrc_osc_noclkout,mclr_off,wdt_off
led Var PORTB.7
x var byte
PORTA = 0 ; PortA low
TRISA = 4 ; RA2 = input
cmcon = 7 ; set port a to digital
INTCON.7 = 0 ; turn off global interrupts
OPTION_REG.6 = 1 ; wake on rising edge
main:
for x = 1 to 10 ' First led flashing pattern
low portb.7 '
pause 200 '
high portb.7 '
pause 200 '
next x '
INTCON.1 = 0 ; clear RA2 interrupt flag in case set (right before @ Sleep command)
@ sleep
goto main
]
Bookmarks