TMRpcm constantly freezing up?

Hey all, long timer lurker here. Finally caved on a problem that I just can't figure out myself.

So I have been using tmrPCM for about a week now and it's really a great tool but I am now starting to run into an issue where if I play a sound enough times, my entire Mega will just freeze up and I will have no choice but to reset it.

I have since removed all other libraries and made it play a short sound on repeat every one second in the loop to try and isolate the problem. Still it persists, after about 4-5 minutes of playing on repeat it has frozen. The only thing going on is the bare-minimum in order to make this sound play. What gives?

The only thing in my loop:

if (millis() > statusTimer) {
statusTimer = millis() + statusTimeAmount;"Hit2.wav");

Anyone have any ideas?

Anyone have any ideas?

Not until you post all of your code so we can try it ourselves.

My apologies, the simplified version of the code that is producing this error is as follows:

#include “SD.h”
#define SD_ChipSelectPin 53
#include “TMRpcm.h”

TMRpcm tmrpcm;

unsigned long statusTimer = 0;
const unsigned long statusTimeAmount = 1500;

void setup(void)

tmrpcm.speakerPin = 5;
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println(“SD fail”);
} else {
Serial.println(“SD Connected”);


pinMode(5, OUTPUT);

void loop() {

if (millis() > statusTimer) {
statusTimer = millis() + statusTimeAmount;“Hit2.wav”);


Thank you for any help you can throw my way.

You don't call stopPlayback() at any point, which might matter, as I don't think the files are
getting closed.

That seems to have done the trick! I will report back with a summary to finish off the thread in a day or two after I have finished playing around with it. Thank you for all your help, this information may be useful to newbies to the library like myself.

So bad news. I left it running over night. I put the sound back on a trigger (Sound is supposed to be played when certain data comes through the serial port). When I came back down in the morning to test it, it worked a couple of times and froze up once again. I will post the full code later tonight when I am back home, but for now this case still seems to be open. Though, it is much better after stopping playback!