Closed asmagill closed 4 months ago
To wake up from (sleep)
with no timeout you have to generate an interrupt, such as a Reset. For an example of using that see:
http://www.technoblogy.com/show?2AMW
I'll check your other point on my ATMega1284P board; won't be able to do that until next week though.
Thanks for the report! David
I've had another look at your report and I think you're correct; The statements:
PRR0 = PRR0 | 1<<PRTIM0;
and
PRR0 = PRR0 & ~(1<<PRTIM0);
should be moved to either side of:
sleep_enable();
sleep_cpu();
in sleep()
. You should then be able to keep the rest of my original code (apart from the unnecessary #if... #endif
stuff.
I'll verify that when I get to my computer.
Regards, David
I can confirm moving those into my ulisp_sleep
function does in fact work.
Great!
I've fixed this on Release 4.6; thanks for pointing it out.
I'm using the latest ulisp 4.4b (as of this posting) on an ATMega1284P with the MightyCore 2.2.2 bootloader and compiling with the Arduino IDE.
This may be related to using the Arduino IDE, but I found 2 issues with using the sleep function...
The relavent code is at https://github.com/technoblogy/ulisp/blob/596440d95c56a4bc48b9f112c1e2f36beddaa366/ulisp-avr.ino#L1983-L2010
First, when compiling I get a redefinition of
void sleep()
from.../avr/2.2.2/cores/MCUdude_corefiles/wiring_extras.h
. Simple enough, just rename the function to something likeulisp_sleep
and change it in the two places it's called, and that cleared up.But when I invoke
(sleep 10)
it would go into sleep mode and never wake up. I tweaked the code a bit to the following and it works again as I expect (I also took out some unnecessary #if... #endif stuff since it was checking the same defines as the one wrapping the whole function withindoze
):My understanding of the low level timers and registers is weak, but I'm thinking it's because we disable
TIMER0
indoze
, but then calldelay
insleep (ulisp_sleep)
...Also, I noticed that it is possible to invoke
(sleep)
with no arguments and it will callsleep (ulisp_sleep)
directly, but I don't discern any way to wake back up... am I missing something somewhere?Have I sussed this out correctly, and should I submit a PR?