-
-
Notifications
You must be signed in to change notification settings - Fork 725
Incompatibility between MKRZERO RTC & I2S libraries #451
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
Comments
Having investigated this, I wonder if it is a clock conflict? |
@white-ar I think you are likely correct regarding the clock conflict. I have not used ArduinoSound but had a quick look. Unfortunately, I cannot locate where the I2C object is actually instantiated so I cannot determine which clock it is using. I2S.h has an external reference but not the actual instantiation with the parameters that indicate which clock is used. Maybe someone more familiar with this library could chime in and tell us where it is instantiated. |
@sslupsky thank you, I am glad I am not the only one who has 'reached a dead end' whilst trying to fault find this. It seems from the Atmel Software Framework (ASF) that it is possible to use different clocks. So, I assume if one of the libraries re configures a clock used by one of the other libraries, this could cause a conflict. As you say, this problem appears to require the help of someone with greater holistic knowledge of the architecture, and I suspect ASF. All help greatly appreciated. |
@white-ar I have found issues with the RTC library and the LowPowerLibrary. I recently added support for using the periodic interval interrupts with the RTC and the event system. This allows you to wake up more often than is possible using the RTC alarm interrupts. There are some defects with the Wire and SERCOM libraries with regard the low power compatibility as well. I proposed some solutions with a PR but they have not been accepted (yet?). |
I wonder if someone got some ideas after two years. I am working on a clock that would play sound alarms using the MKR WIFI 1010. The board would freeze when trying to play a file. I took hours to realize that removing any line that touched the RTC, would allow the board to play the sound. |
@aoriani Hi Andre, I never managed to get it to work, and gave up on making a battery powered version. @sandeepmistry : was there a resolution to this issue? I'm sorry, I can't be of further assistance. |
@white-ar thanks a lot for your response. It looks like you were the pioneer on this issue because every Google search hits a post of yours. If I correctly followed your saga, you ended using an external RTC and you could not use the LowerPower lib because it faced a similar problem. Is that a precise account? Someone mentioned on https://forums.adafruit.com/viewtopic.php?f=25&t=182648 that the possible root cause was the RTC lib enabling protection on a register needed by I2S. So I wonder if the incompatibility is at the hardware level, or is there still hope that it could be solved thru software? |
@aoriani My project was an alarm clock that played music. The issue being that unless one puts the Arduino into low power mode (sleep) it draws too much power to be viably from battery power. The RTC was used to keep time when the Arduino is switched off, or between battery changes, etc. You may note from the code snippet above, this is standard Arduino example code, with the simple addition of the standard RTCzero library. Put another way - the issue is within the standard libraries. I started investigating the underlying libraries and register architecture, however it soon became clear that I didn't have enough background knowledge to make any meaningful progress in this regards. My project succeeded in its wider goal, so all was not lost. If you 'need' to get this working, you could try a pair of Arduinos, using an interrupt to signal between them. i.e. one handles the RTC, then wakes the Zero to play audio. (Note: Also, you'd need to message time and alarm time, etc, between them as well.) Hope this helps. |
Hey everyone. I ran into this issue recently and found a fix that seems to work so far. The issue has to do with clock conflicts as many of you have suspected. When the RTCZero library configures the clock it sets the bit value of DIVSEL in the GLCK GENCTRL register to 1. I2S expects this value to be 0 but doesn't explicitly set its value. To remedy this all you have to do is add this line in the I2S library within the ( void I2SClass::enableClock(int divider) ) function. GCLK->GENCTRL.bit.DIVSEL = 0; Below is where that line of code goes. |
There appears to be an incompatibility between the ArduinoSound.h and RTCZero.h libraries.
When you try to play an audio file after the internal RTC has been initialised, the WAV files won't play. See the
rtc.begin()
function call in the code below.Configuration: MKRZERO and Adafruit MAX98357A I2S audio board.
The text was updated successfully, but these errors were encountered: