-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Sleep mode for Arduino #13321
Comments
Welcome to RIOT @catcombo! Using xtimer here is a bit tricky, as it is not 100% compatible / designed for being used in sleep modes. ATmega328p uses the 16bit timer (Timer 1), as it is required for the resolution of xtimer. It uses the Checkout #8207 for my PR on sleep modes for the atmega CPUs. At this point I am afraid to say, that you cannot use |
@roberthartung Thank you very much for your explanations! I thought it will be easier and more common way (thanks to RIOT) to use a sleep mode :\ I planned to create a thread and put it into a sleep every 5 minutes. If I understand correctly if I want to use deep sleep modes I need to use interrupts (or Watchdog timer? I saw some people do so in Arduino) to wake up after a certain amount of time. Is there any convenient way to use interrupts in RIOT rather than direct use of AVR libraries? I also thought that in SLEEP_MODE_IDLE MCU will sleep until the end of xtimer interval but it seems it wake up multiple times a second. If I understand correctly there are other interrupts in the system that cause MCU to wake up and do some job. Is there a way to get the list of active interrupts to understand their purpose? |
@catcombo You're welcome. Using sleep modes in RIOT is in theory very easy (once the PR is merged that introduces 'native' sleep modes using pm_layered). However, using sleep modes in a fully stacked operating system is a big challenge. Therefore we created the RIOT features the irq interface. You can use it right away to enable interfaces. Additionally, you can use the GPIO module to enable external interrupts. You are mixing avr code (set_sleep_mode) and RIOT code here. In theory this should be hidden from you! A list of interrupts is not available. For clarification: You would like to do something and then wake up every five minutes for the same task, correctly? |
Thanks for links to documentation and for explanation! It's all a bit hard for me now but I will try to figure out and understand how everything works to not bother you too much with a newbie questions :)
Yes, simple periodic task: get temperature from DS18 sensor, display it on HD44780 display, then sleep for 5 minutes to wake up and repeat the cycle. |
We now have ztimer that is compatible with low power modes. However, the AVR port has no (But given that modern 32 bit controllers are faster, cheaper, have more RAM/flash and require less power all at the same time, one might just go for one of those MCUs instead. Anyways, I think the issue can be closed. A tracking issue for which platforms are still missing |
Description
xtimer_sleep
doesn't wake up an Arduino from sleep mode. I think I do something wrong but can't find out what excactly. I'm trying to migrate from Arduino framework to RIOT OS so don't be too hard on me :)Steps to reproduce the issue
Expected results
Wake up every 10 seconds.
Actual results
Hangs after first call to
sleep_mode()
.Versions
Hardware: Arduino Nano (ATmega328p).
The text was updated successfully, but these errors were encountered: