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

Thread: Serial issue with Teensy 3.5 and Audio Board

  1. #1
    Member
    Join Date
    May 2013
    Location
    Montreal
    Posts
    34

    Serial issue with Teensy 3.5 and Audio Board

    I've soldered a new audio board directly to a new Teensy 3.5 in the recommended layout. I have tested all the connections with the pins to make sure that they are solid.

    I am trying to run the WavFilePlayer example with an SD card in the Teensy 3.5. It loads and the onboard LED illuminates, however my audio file that worked with a Teensy 3.2 and audio board does not play. Notably, the Serial port disappears as well (ie: port: [no device] (Teensy 3.5) Serial.) so it's difficult to trouble shoot.





    Here is my code:

    // Simple WAV file player example
    //
    // Three types of output may be used, by configuring the code below.
    //
    // 1: Digital I2S - Normally used with the audio shield:
    // http://www.pjrc.com/store/teensy3_audio.html
    //
    // To configure the output type, first uncomment one of the three
    // output objects. If not using the audio shield, comment out
    // the sgtl5000_1 lines in setup(), so it does not wait forever
    // trying to configure the SGTL5000 codec chip.
    //
    // The SD card may connect to different pins, depending on the
    // hardware you are using. Uncomment or configure the SD card
    // pins to match your hardware.
    //
    // Data files to put on your SD card can be downloaded here:
    // http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
    //
    // This example code is in the public domain.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    AudioPlaySdWav           playWav1;
    // Use one of these 3 output types: Digital I2S, Digital S/PDIF, or Analog DAC
    AudioOutputI2S           audioOutput;
    AudioConnection          patchCord1(playWav1, 0, audioOutput, 0);
    AudioConnection          patchCord2(playWav1, 1, audioOutput, 1);
    AudioControlSGTL5000     sgtl5000_1;
    
    // Use these with the Teensy Audio Shield
    //#define SDCARD_CS_PIN    10
    //#define SDCARD_MOSI_PIN  7
    //#define SDCARD_SCK_PIN   14
    
    // Use these with the Teensy 3.5 & 3.6 SD card
    #define SDCARD_CS_PIN    BUILTIN_SDCARD
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   13  // not actually used
    
    void setup() {
      Serial.begin(9600);
    
      // Audio connections require memory to work.  For more
      // detailed information, see the MemoryAndCpuUsage example
      AudioMemory(80);   // I changed this to see if it helps, it didn't
    
      // Comment these out if not using the audio adaptor board.
      // This may wait forever if the SDA & SCL pins lack
      // pullup resistors
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
    
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        // stop here, but print a message repetitively
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
    }
    
    void loop() {
     if (!playWav1.isPlaying()) {
        playWav1.play("TTS-20M.WAV");
        delay(10);
        Serial.println("it's playing.");
     }
    }
    I tested this setup with the listfiles example in the SD examples and it successfully lists the files on the card. The Serial port does not disappear.

    I tested this setup with the tonesweep example and it plays.

    Sorry to bother you if it is a simple issue but I cannot google the solution so far.

    Thanks so much for your assistance,

    Erin
    Last edited by defragster; 08-09-2019 at 11:06 PM. Reason: added # CODE block

  2. #2
    Member
    Join Date
    May 2013
    Location
    Montreal
    Posts
    34
    Ah sorry you might notice I took the Serial out entirely - you can assume I just am using the regular old example code.

    I'm on a Mac 10.14.5

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,948
    Perhaps … For Audio Card the SPI adjustments are needed , for using the T_3.5 native SD only the CS_PIN line is needed.

    // Use these with the Teensy Audio Shield
    //#define SDCARD_CS_PIN 10
    #define SDCARD_MOSI_PIN 7
    #define SDCARD_SCK_PIN 14

    // Use these with the Teensy 3.5 & 3.6 SD card
    #define SDCARD_CS_PIN BUILTIN_SDCARD
    // #define SDCARD_MOSI_PIN 11 // not actually used
    // #define SDCARD_SCK_PIN 13 // not actually used
    That should be the right direction - if not all that is needed …

    But not using SPI on the Audio card then maybe these lines are not needed?
    Code:
    //  SPI.setMOSI(SDCARD_MOSI_PIN);
    //  SPI.setSCK(SDCARD_SCK_PIN);

  4. #4
    Member
    Join Date
    May 2013
    Location
    Montreal
    Posts
    34
    Hmm, just tried it, same results. I get a click in my headphones at the beginning in both cases, which implies to me that the audio is uh, alive, but not much else in terms of response.

  5. #5
    Member
    Join Date
    May 2013
    Location
    Montreal
    Posts
    34
    I have a fully updated Arduino and Teensyduino as well. The act of playing the audio itself seems to be what is causing the problem. I have methodically added the code in line for line in order to see precisely what causes the issue and it's playing the WAV.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,948
    I copied those lines of usage from the SD example :: ListFiles.ino

    Start with a simple sample like that to make sure the " BUILTIN_SDCARD " is working without issue.

    Then maybe try an Audio example using the AUDIO BOARD SD adapter to see that working.

    I don't recall if there is an example using Audio and the T_3.5 BUILTIN_SDCARD - or that I've done it and may be missing something obvious?

  7. #7
    Member
    Join Date
    May 2013
    Location
    Montreal
    Posts
    34
    I have used the ListFiles.ino in order to verify that the 3.5 SD works. I have actually gotten everything working using the Audio Adapter SD card.

    So this issue doesn't make or break my project because it's my first time using this setup and I guess it just means I have to continue using the Audio Adapter SD card, but I find it baffling that I cannot use the Teensy 3.5 SD while plugged into the Audio Adapter because it disconnects the serial.

    I find it stranger that I might be the first person to come up with this issue because I'd assume that users of the 3.5 have been connecting to the audio board and using the 3.5 SD? But the fact that the serial disconnects makes me think it might be an issue with my OS or something.

  8. #8
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,232
    There is a known bug with AudioPlaySdWav and BUILTIN_SDCARD as of Teensyduino 1.46. That may be your problem, Here is a hack/fix
    https://forum.pjrc.com/threads/56355...l=1#post206982
    Problem has been noted in several threads ... it affects T3* and T4

  9. #9
    Member
    Join Date
    May 2013
    Location
    Montreal
    Posts
    34
    Thanks so much manitou. I suspected it was something like this but I found that googling some key words didn't bring up those threads. So hopefully this thread will help others.

  10. #10
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,232
    Re: bug with AudioPlaySdWav and BUILTIN_SDCARD

    FYI, Paul has provided official FIX, get the latest SD lib at https://github.com/PaulStoffregen/SD

Posting Permissions

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