-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLEEP_MODE_IDLE return without entering sleep #113
Comments
@bobcmartin any hint 🙃 ? |
@facchinm I figured out a possible reason, on SLEEP_MODE_IDLE, interrupt is trigger every 1 ms (presumably for the millis() function to update) thus the board return to running the code. To deal with that, I currently use a FOR loop to loop e.g. 1000 times if I wamt to sleep for 1000ms. Not sure if that is the reason behind and is the intended outcome, but it works at leaat. |
@chansheunglong good to hear that, it would have been my first option for investigation (since it's very similar to what happens on other architectures). |
The best way to do this is to configure the RTC peripheral using it's PIT, Periodic Interrupt Timer. The PIT can be clocked from the internal ultra low power 32kHz oscillator. It was added to mega4809 specifically for the purpose of waking up after a specific time in sleep mode. The millis() timer interrupt needs to be disabled or the timer shut off, configuring the RTC PIT function and then calling the SLEEP function. It's then a choice of adding the appropriate number of ticks to the millis() base counter before starting the timer again. |
The other issue, assuming the target board is a Nano Every, is that the SAMD11 is still in active mode, so unless it's completely decoupled from the mega4809 it doesn't really matter since the current numbers won't be close to datasheet numbers. I'm deciding between removing a bunch of parts from a Nano Every board or continuing the search for my mega4808 breakout board |
Everything works fine with Standby and Power-Down, the device goes to sleep forever without waking up
But I would like to have
millis()
running since I need to keep track of the timeI change to
SLEEP_MODE_IDLE
(SLPCTRL.CTRLA |= SLPCTRL_SMODE_STDBY_gc;
)to have the main clock runningHowever, after that, the device just exits sleep mode immediately. And output "ERROR" to the terminal
Two question that need help:
millis()
active?Thanks all!
The text was updated successfully, but these errors were encountered: