Okay, I'm confused with interrupt causing a wake from deep sleep. Maybe there's someone out there who knows about kissing the (sleeping) princess?
I'm running a 28x2 and wanting to put it into deep sleep (sleep 0) until my RTC says it's time to do your thing. I've found setting up interrupts to be somewhat less than intuitive, so I wrote a little test program first to make sure the PicAxe would do what it was supposed to.
I set up on hint2 (pin B.2) so that my RTC (DS3231) would send an alarm pulse (pulling B.2 low .. it has a pullup to keep it high otherwise). That was supposed to wake up my PicAxe to read the sensors and then go back to sleep for a while. The test program was to verify the activity of the interrupt before committing to the entire code.
Oddly enough, my test code works ... but doesn't. The code responds to the pulse on B.2 but it does not run anything that is contained in the interrupt sub. Is this by design? Certainly, I can code around it. But I want to be sure I'm not doing something wrong. It aprears that using an interrupt to wake from deep sleep does ONLY that and nothing else that might be contained within the interrupt sub. Can someone verify ... or tell me what I'm doing wrong? When I run the test code, I see only "sleep" and "wake" and not "int" or "msg" as I expected.
Also, it doesn't seem to make a difference if I include the "setintflags" line in the interrupt code as seems to be recommended in the docs.
Here's the test code:
#picaxe 28x2
#terminal 9600
#simspeed 10
#no_table
hintsetup %00000100
SETINTFLAGS %00000100,%00000000 ;interrupt for B.2 low pulse
main:
sertxd("sleep",cr,lf)
sleep 0
sertxd("wake",cr,lf)
goto main
end
message:
sertxd("msg",cr,lf)
return
interrupt:
sertxd("int",cr,lf)
call message
return
I'm running a 28x2 and wanting to put it into deep sleep (sleep 0) until my RTC says it's time to do your thing. I've found setting up interrupts to be somewhat less than intuitive, so I wrote a little test program first to make sure the PicAxe would do what it was supposed to.
I set up on hint2 (pin B.2) so that my RTC (DS3231) would send an alarm pulse (pulling B.2 low .. it has a pullup to keep it high otherwise). That was supposed to wake up my PicAxe to read the sensors and then go back to sleep for a while. The test program was to verify the activity of the interrupt before committing to the entire code.
Oddly enough, my test code works ... but doesn't. The code responds to the pulse on B.2 but it does not run anything that is contained in the interrupt sub. Is this by design? Certainly, I can code around it. But I want to be sure I'm not doing something wrong. It aprears that using an interrupt to wake from deep sleep does ONLY that and nothing else that might be contained within the interrupt sub. Can someone verify ... or tell me what I'm doing wrong? When I run the test code, I see only "sleep" and "wake" and not "int" or "msg" as I expected.
Also, it doesn't seem to make a difference if I include the "setintflags" line in the interrupt code as seems to be recommended in the docs.
Here's the test code:
#picaxe 28x2
#terminal 9600
#simspeed 10
#no_table
hintsetup %00000100
SETINTFLAGS %00000100,%00000000 ;interrupt for B.2 low pulse
main:
sertxd("sleep",cr,lf)
sleep 0
sertxd("wake",cr,lf)
goto main
end
message:
sertxd("msg",cr,lf)
return
interrupt:
sertxd("int",cr,lf)
call message
return