arduino / arduino/ArduinoCore-megaavr
SLEEP_MODE_IDLE return without entering sleep
- Dominant language
- C++
- Stars
- 111
- Forks
- 65
- PR merge metrics
- No merged PRs in 30d
Description
Everything works fine with Standby and Power-Down, the device goes to sleep forever without waking up
```
void loop() {
SLPCTRL.CTRLA |= SLPCTRL_SMODE_PDOWN_gc; //SLEEP_MODE_PWR_DOWN
sleep_enable();
sleep_cpu();
sleep_disable();
Serial.println("ERROR"); //If you see this there is an error
Serial.flush();
}
```
But I would like to have `millis()` running since I need to keep track of the time
I change to `SLEEP_MODE_IDLE` (`SLPCTRL.CTRLA |= SLPCTRL_SMODE_STDBY_gc;`)to have the main clock running
However, after that, the device just exits sleep mode immediately. And output "ERROR" to the terminal
Two question that need help:
1) Is there any config I need to do for the MCU to go to IDEL mode and enter sleep?
2) While in STANDBY and PWR_DOWN, is there anyway to keep `millis()` active?
Thanks all!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the reported loop and the SLPCTRL sleep-mode settings, then trace how sleep_cpu() behaves for SLEEP_MODE_IDLE, STANDBY, and PWR_DOWN. Check whether the selected mode permits the clock source used by millis(); done means explaining the immediate return and determining whether millis() can remain active in the requested modes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100