Teensy 4 suddenly gets stuck in the AudioShield Setup and blocks COM access

Status
Not open for further replies.

zuziz

New member
I use a Teensy 4.0 with the AudioShied revD. I aim to build a sound reactive LED controller for a club. I program and upload the code in vscode with platformio on Windows 10.
My code worked well but suddenly after trying to upen the serial monitor everything stopped. The serial monitor itself freezed and i couldn't upload new code automatically. I had to change the cable even it worked for months and uploaded the blink code in the Arduino IDE. One thing is, I have to always press the manual button for it to work.
The blink code works well. I then change to my other code, upload it and the teensy freezes completely again.
The serial monitor tells me sometimes, that the setup started, but it never finishes.
When I try to reupload code, I get and it disappers from the device manager and all IDEs:

Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch.
Unable to open COM3

I have to press the button to upload code again. Example sketches work well, but when I try to upload my other code nothing happens. It doesn't even start the setup now.
I rebootet about 10 times and unplugged but no change. I didn't change code when it happened so that's what confuses me the most. My code of the main file is below:
Code:
#include "ledcontrol.h" // own library for led controlling
#include "soundReader.h"

//bpm analysis variables
unsigned long varthresh = 30000;

/********************Teensy Audio*************************/
const int myInput = AUDIO_INPUT_LINEIN;
AudioInputI2S audioIn;
AudioMixer4 mixer;
AudioAnalyzeRMS rms;
AudioAnalyzeFFT256 fft256;

AudioConnection patchCord1(audioIn, 0, mixer, 0);
AudioConnection patchCord2(audioIn, 1, mixer, 1);
AudioConnection patchCord3(mixer, fft256);
AudioConnection patchCord4(mixer, rms);

AudioControlSGTL5000 audioShield;

/********************Setup Loop*************************/
void setup()
{
  Serial.begin(38400);
  Serial.println("Setup started");

  pinMode(LED_BUILTIN, OUTPUT);

  mixer.gain(0, 0.5);
  mixer.gain(1, 0.5);
  mixer.gain(2, 0);
  mixer.gain(3, 0);

  AudioMemory(10);
  audioShield.enable();
  audioShield.inputSelect(myInput);
  audioShield.volume(0.5);

  Serial.println("Setup finished");
}

/**************************Main Function Loop*****************************/
void loop()
{
  //main animatin class
  SoundReader reader = SoundReader(fft256, rms);
  LedController ledcontroller = LedController(reader);

  //Median calculation classes
  RunningMedian samples = RunningMedian(10);
  RunningMedian samplesMed = RunningMedian(10);
  
//analyse the fft, find kicks and do the animation
  while (true)
  {
    ledcontroller.updateKick(reader.readData());
    ledcontroller.check();
  }
}
 
Last edited by a moderator:
Somehow it suddenly worked again after drinking a coffee and not touching it for a while so it is "fixed".
 
Status
Not open for further replies.
Back
Top