Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

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

  1. #1
    Junior Member
    Join Date
    May 2021

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

    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:
    #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.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);
      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)
    Last edited by Frank B; 05-21-2021 at 10:24 AM. Reason: Missing Code Tags

  2. #2
    Junior Member
    Join Date
    May 2021
    Somehow it suddenly worked again after drinking a coffee and not touching it for a while so it is "fixed".

  3. #3
    Senior Member ETMoody3's Avatar
    Join Date
    Mar 2014
    New Ulm, Mn
    This is why you never code before coffee

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts