-
Notifications
You must be signed in to change notification settings - Fork 58
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
Clock disabling code looks wrong #30
Comments
I am having a similar problem using this library with a FEATHER M0/RFM69 BOARD ADAFRUIT PID:3176 for RTC and pin wakeups. The radio tries to send one packet and fails then the command for sleep(2000) is executed and the the board never wakes up again. Have you tried your suggested change to the library? |
Yes. My change does fix the problems I was having. |
Thanks, it fixed my RFM69 problem too although Serial still stops working which, I guess, is a separate issue. |
You saved me! Thanks!!! Tha arduino MKR 1310 can't work with an ADCInterrupt and a timed sleep at the sime time. But this fixes it. I'll make a pull request |
This commit fixes issue arduino-libraries#30
@denisbaylor @PhilGoody |
Fixed my problem with the Feather M0 LoRa radio, too. Now sleep modes can be implemented for the SAMD21 in the RadioHead library! For the details see https://forums.adafruit.com/viewtopic.php?t=211308 It is very sad that the library maintainer(s) can't be bothered commit this simple fix to a serious error in the library. |
ArduinoLowPower/src/samd/ArduinoLowPower.cpp
Line 9 in 6fd308a
The comment at this line says "disable GCLK module". But my reading of the somewhat ambiguous documentation of the CLKCTRL register is different.
I believe each generic clock id has its own enable (although I don't see this spelled out clearly in the documentation). The documentation for CLKCTRL says:
I believe what line 9 is actually doing (via a forbidden 8-bit write), is setting the enable to 0, setting the GEN field to 0 (which means select generic clock generator 0) and then applying these changes to the ID field that last happened to be set. So it's essentially disabling and corrupting the clock source for the most recently configured clock generator ID. Things will work ok if you don't intermingle this low power code with other libraries that configure clocks. In my case, trying to add an interrupt between calls to other library code (Adafruit_SSD1306) caused that other code to hang. I believe the reason that code hangs is that the clocks to SERCOM2 had been disabled by this bug.
As I understand things, this line should be:
The text was updated successfully, but these errors were encountered: