This is a tricky one that I can't get to the bottom of....I'm at a loss now and throw myself open to the forum for help!
Ok, here's what I'm doing, I'm putting a PIC to sleep, just before doing so, I enable IOC DT interrupts....
Code:
IOCAF = 0 'clear the interrupt flag
@ INT_ENABLE IOC_INT ' enable IOC interrupts
PAUSE 50 'wait a little
@ sleep ' put the PIC to sleep
Ok, so far so good, my PIC goes to sleep
So now when a switch gets pressed. the PIC gets woken up by an IOC Interrupt - I have a fair splattering of debug lines in the interrupt routine - I can see the program enter the IOC Interrupt routine (debug line at the top of the routine) & exit (another debug line at the end of the routine) - again so far so good.
Now from my weak understanding of waking from sleep, I believe the program picks up from the line of code immediately after the @sleep line (above), so here's what follows the @sleep line in my program...
Code:
@ sleep ' put the PIC to sleep (ie same entry as above, shown here to show the flow of things)
'here's what follows & should be where the PIC picks up...
pause 5
TrisA.0 = 0 ' make the nominated debug pin an output
debug "awake",13,10
So when all is working well, with the PIC being asleep, after a switch is pressed (to wake up the PIC), I should see my IOC interrupt 'entry' debug line, my IOC interrupt 'exit' debug line & then the word "awake" (ie the line of code immediately following the @sleep command)
So what's the problem?
Well as my thread title suggests...it's not robust - if I press the switch to wake the PIC ....about 7-10 times it wakes up fine on the trot, but then a problem occurs & my program appears to go nowhere(!) - the last thing debug line I see on my screen is my IOC interrupt 'exit' debug entry.....and nothing else after that (in other words I don't see the debug line "awake" onscreen)
I have no idea where my code is (ie where the code is at!)....any ideas how to debug this one?
I'd appreciate a bit of input as I'm worn out!!!
Bookmarks