AloyseTech / Zerodio

Non blocking audio library for Arduino Zero
9 stars 0 forks source link

Program is getting stuck after playing audio #2

Open classyCaveman opened 8 years ago

classyCaveman commented 8 years ago

I'm trying to work with this library to play some non-blocking audio files in my project. I started by working with the posted example file but I'm finding that the program crashes/gets stuck after the audio file is played through the speakers.

Do you have any ideas as to why this is happening?

Note: I am working with the Adafruit Feather M0 Adalogger which uses the same chip as the Arduino Zero.

AloyseTech commented 8 years ago

HI, Do you know if you use Timer Counter TC5 somewhere in your program? Like for example Tone()? Is the audio file well played before the program crash? Please use pastebin to share your code so I can take a look.

classyCaveman commented 8 years ago

Just double checked my project file and none of the other libraries use the TC5 counter. This shouldn't make a difference when running the example file though. Attached is the modified example file that I am running on my board. The only changes I made are to the Chip Select Pin and the name of the sound file on the SD card.

The file plays fully and sounds as it should before the program crash.

Zerodio_Example.zip

AloyseTech commented 8 years ago

Could you please send me your audio file? I will try it myself on my board.

classyCaveman commented 8 years ago

I just reconverted everything into those settings to make sure all is well and the problem is still present.

classyCaveman commented 8 years ago

I played with the cpp file a little bit and I found the problem to be that the code was not coming out of the loop in the source file. I threw a return in function after line 54 which made the code run well for me. I tried the same thing by adding a return after line 69 (removing the one from 54) and found that the outcome was still good.

The problem that I'm facing now is that the sound stops working, program doesnt crash, fully after file 26 (all files play in consecutive order starting with 1, going to 40). The sound files are each one second long.

Is there anything that you know about the timers or how the memory is stored that I could adjust in the code to make sure this does not happen? Could it just be that the return function that I placed is throwing everything off?

AloyseTech commented 8 years ago

You should not place a return at line line 55 just after the file.open I think. The issue you're having is very strange, because 26 files play correctly. You could maybe try to add a TCdisable() in line 53 in the if statement. Maybe an interrupt is generated at a bad moment.