VS1053 breaks after 12 hours. Please help me fix this. Please.

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
drewbeathard
User
Posts: 2
Joined: Tue 2022-03-08 5:59

VS1053 breaks after 12 hours. Please help me fix this. Please.

Post by drewbeathard »

Hi,
I'm embarrassed to say that I have been trying to fix this problem for the better part of 2 months and I still haven't found a viable solution. The problem is: After a certain amount of time, say 8-12 hours, my Adafruit Music Maker shield connected to arduino uno breaks- it stalls out and seems to be playing many different notes at once. I have been through both the arduino and Adafruit forums and haven't been able to figure this thing out. Here is the adafruit discussion: https://forums.adafruit.com/viewtopic.php?f=31&t=188518

As you can see, the music shield is part of a pretty cool project and it is a shame that this component is not working as I intended. I have tried to do the following things:
  • Fix the actual problem, as in making the music shield NOT break after 12 hours. Honestly I have no idea why this is happening in the first place, there was a discussion on this site about possible push / pop stack misalignment or something but I think we concluded in the last forum that this wasn't the same issue. Kinda got a little confused here. So I pretty much gave up trying to solve this issue. If you have any suggestions, please let me know.
  • Make the shield RESET after a certain amount of time, say 3 hours, so that whatever issue that arises after 8 hours is always prevented. It appears that the reset command in the test MIDI script found at https://github.com/adafruit/Adafruit_VS ... ditest.ino is NOT actually resetting the chip in the way that I want:

    Code: Select all

      
      pinMode(VS1053_RESET, OUTPUT);
      digitalWrite(VS1053_RESET, LOW);
      delay(10);
      digitalWrite(VS1053_RESET, HIGH);
      delay(10);
      
    The reason I say this is not working how I want is because when the problem does arise, I am able to press the RESET button on the Adafruit Music Maker Shield and it DOES fix the issue. I was hoping the accomplish the same result by resetting the 1053 chip programmatically but it appears that it is not actually doing anything.
So yeah right now I am only working with the UNO and the music maker shield powered by a 5v wall adapter. I have also tried doing a hard reset of the UNO in combination with the 1053 reset command in the SETUP section of the script so that the UNO and the 1053 reset together after a certain amount of time - this also failed miserably.

Right now I am just running the sample midi program (linked above) with the 1053 reset command every 15 seconds.

The solution I am looking for does not have to be perfect. It can be ugly. I don't care. I just want this thing to work. Thank you
User avatar
pasi
VLSI Staff
Posts: 2019
Joined: Thu 2010-07-15 16:04

Re: VS1053 breaks after 12 hours. Please help me fix this. Please.

Post by pasi »

Using the xRESET pin of vs1053b really does reset everything, so at a glance it looks like there's some initialization in the Arduino that is missing.

About the issue itself: It seems there is indeed a maximum time a file play and also the real-time operation will work correctly. The elapsed absolute time (in samples) is counted and all note-on / note-off events get similar absolute time stamps. Being signed 32-bit values, the time when the value becomes negative is 2^31/44100Hz = 13 hours 31 minutes and 36 seconds, which matches close enough to your experience.

The MIDI decoder was initially only playing files, so this limit was probably deemed not to be an issue. When making the real-time MIDI, checking this never occurred, and it probably isn't an issue in most cases anyway.

The parsing of midi messages will still work. It doesn't use the absolute time. But signed comparisons of note-on and note-off will be reversed.

One joking workaround is to let it play another 13 hours 31 minutes and 36 seconds, and it will correct itself.

Do you have access to the Serial Control Interface with the shield? Are you loading the real-time-MIDI patch? I could try to add a workaround in that.
Edit: if yes, test this:
rtmidi1053b.plg
hand-clap fix, should play for longer than 13:31.36
(9.29 KiB) Downloaded 63 times
Note: completely untested.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
drewbeathard
User
Posts: 2
Joined: Tue 2022-03-08 5:59

Re: VS1053 breaks after 12 hours. Please help me fix this. Please.

Post by drewbeathard »

Hi Pasi,
Thank you for taking the time to help me out.
It sounds like you actually know what is causing this problem which is good to hear.

My first thought would be to see if we can figure out what is going on with the reset function and just fix that. You mention that it appears some initialization in the Arduino is missing. I don't understand what this could be. My arduino and shield are configured exactly as demonstrated in the Music Maker demo (check the image attachment). Could you please elaborate on what could be causing my RESET call to fail? The documentation talks about the class Adafruit_VS1053 which has both hard and soft reset calls. This is where it gets a little unclear to me- am I using one of these functions when writing my reset pin to high?

Then you move on to solving the actual root of the problem. To both of your questions: I don't know, I don't even know what the real time MIDI patch is. I don't think I have access to any interface with the shield. Please see page 19 of https://cdn-learn.adafruit.com/download ... layer.pdf for an exact description of what I am using right now.
If there's any other information I can provide you about my system please let me know. Even though the project is more complicated, I have isolated the issue to this very simple setup, only running the basic MIDI test script.

Please let me know if you have suggested steps forward, thanks.
Attachments
Screen Shot 2022-03-08 at 8.03.06 PM.png
Screen Shot 2022-03-08 at 8.03.06 PM.png (290.32 KiB) Viewed 518 times
User avatar
pasi
VLSI Staff
Posts: 2019
Joined: Thu 2010-07-15 16:04

Re: VS1053 breaks after 12 hours. Please help me fix this. Please.

Post by pasi »

Unfortunately I can't help with the shield itself, just the observation that if reset on the shield manages to play correctly, then resetting vs1053b and performing the same functions should also play correctly.

Does the controller have a watchdog?

One of our tricks for restarting a firmware and resetting all peripherals is triggering a watchdog reset intentionally.


The library seems to have e.g. "void applyPatch(const uint16_t *patch, uint16_t patchsize);". Using that you could load the midi patch above. You may need to try to find some examples that use it first.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply