Sleep mode Interrupts

danion64

New Member
Greetings,
I'm new here. I'm just getting into the picaxe--it appears to be a great system.

Like many others, I'm interested in chip power consumption, battery/solar operation, low-power standby modes, etc. I've been consuming the posts on underclocking, sleep mode, auto-poweroff circuits, etc.

Sleep mode is less than fully described in the manual. It has a 2.3s time base, which is the max delay using another method...and I read (or was it implied) that the device "wakes from sleep" each 2.3s during an extended sleep interval...that got me wonderng:

Does the picaxe respond to interrupts during sleep (at least every 2.3 seconds...)?

This was addressed here in 2005:
http://www.picaxeforum.co.uk/showthread.php?t=1014&highlight=sleep+interrupt
In the above "Technical" seems to respond that no, it does not.

I know there have been changes in the firmware/software over the years...i.e. we now have software configurable 'disablebod', so perhaps things have changed in this regard too?

As my chips are in the mail, all I could do was simulate a program to try to answer my own question:

Code:
#picaxe 08m
setint %00000010, %00000010
high 4
main:
	pause 1000
	toggle 4
	sleep 10
	goto main
interrupt:
	high 2
	setint %00000010, %00000010
	return
The simulator behaves contrary to what "Technical" stated in 2005. The interrupt is 'caught' appropriately.

So....what will I find in reality?

(If this is redundant, or is a known bug with the simulator, I apologize in advance...I've done quite a bit of searching but would never claim to have done exhaustively so)
 

hippy

Ex-Staff (retired)
Does the picaxe respond to interrupts during sleep (at least every 2.3 seconds...)?

This was addressed here in 2005:
http://www.picaxeforum.co.uk/showthread.php?t=1014&highlight=sleep+interrupt
In the above "Technical" seems to respond that no, it does not.
Welcome to the PICAXE forum,

The SLEEP lasts multiple units of 2.3s ( approximately - it can vary due to manufacturer's tolerances outside Rev-Ed's control ), during that time of sleeping interrupts will not have any effect but interrupts will be responded to when the sleep period expires.

So, yes, with a 2.3s sleep (sleep 1), the PICAXE can respond to interrupts every 2.3s. With a 23s sleep (sleep 10) the interrupt will only be checked every 23 seconds.

The only thing to bear in mind is that PICAXE interrupts are level sensitive; the input pins used for interrupting are masked and then compared with a match value. The match must be held from whenever it is asserted to when the interrupt is checked ( at the end of the sleep period ) to cause an interrupt.
 
Last edited by a moderator:

Dippy

Moderator
How quickly do things need to respond from 'sleep'?

Could you do a 'nap' in a loop and do a check for pin status at the end of each nap?
i.e. a 'compare' rather than a real interrupt.

And the thing that you want to trigger an interrupt; how long does it assert a pin? (Just contnuing on from hippy's comment).
If the thing is a very fast blip on a pin then you may be a bit snookered unless you can prolong the pulse.
But if it just someone pressing a button, you may be OK with nap-in-a-loop - as even I could hold a button down for 20mS :)
 

danion64

New Member
Thanks for the responses!

Hippy:
There must be a problem with the picaxe emulator. The code sample above responds to the interrupt during the Sleep 10 command, and though I know the emulator does not operate in "real time" the interrupt response seems immediate, not in 2.3s increments.

Dippy:
The nap command could of course work. It would give a finer resolution of response. (I am indeed thinking of a momentary mechanical switch for the interrupt input).

Ibenson:
Thanks for the link. I am exploring all the exciting options open with this product family. I do like the underclocking.
 
Top