Audio Tutorial - Step 1-4/1-5 Blink Testing While Playing Music

Frittions

New member
Hello,

I am very new to the Teensy, so I have been working my way through the Audio tutorial workshop:

https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015

I have been able to complete the Section 1 of the tutorial. Here is a picture of my set-up:

setup.JPG
Teensy 4.1 with Rev D audio shield

*Note: All connections to the audio shield are soldered.

However, after much trial-and-error, I cannot get the LED to blink while playing music, steps 1-4 and 1-5. I traced the issue in the source code and found that the line...

pinMode(13, OUTPUT)

... is causing the issue. If I comment out this line of code and run the program, I hear the music and all other concurrent functions (ie. printing to process monitor, delays, etc.) work as expected.

After figuring this out I put a new number into the pinMode() method (ie. pinMode(2, OUTPUT)), and the program ran as expected.

Finally, I put in the original code and found where there program is crashing:

void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing");
playSdWav1.play("SDTEST3.WAV");
Serial.println("test");
delay(10); // wait for library to parse WAV info
}

The added println statement (Serial.println("test")) will not be executed. Therefore, I'm assuming that the line playSdWav1.play("SDTEST3.WAV") is what is causing the program not to work. Other than this println statement, I have not modified the code in any way. Additionally, I don't think there is anything wrong with my LED because I can ran the example blink testing program without issue.
 
If you are using the audio examples for playing music from the SD reader on the micro SD card reader on the audio adapter shield, you can't use pin 13 for a LED (and hence you can't use examples 1-4 and 1-5 without modification).

The reason is pin 13 is used by the SD card reader (and for reading flash memory if you've soldered it to the audio adapter). The audio adapter uses pins 10, 11, 12, and 13 to access the card reader (pin 10 is the CS pin, pin 11 is MOSI, pin 12 is MISO, and pin 13 is SCLK). So if you write to pin 13, it can mess things up for the SD card reader.

The simplest approach is to change the example to comment out the original code that begins with '#define SDCARD', and to use the lines that are for the Teensy 3.5 and Teensy 3.6 for using the built-in SD card reader. Then move the micro SD card to the Teensy's card reader. The built-in card reader does not use the standard SPI pins (11, 12, and 13). This means you are free to use the LED for blinking.

In the Teensy 3.2 that the examples for written for, pin 13 is used for reading audio input, and pin 14 is used for the SD card drive.

If you don't want to use the built-in micro SD card reader (or you have a Teensy 4.0 which does not have a micro SD card reader by default), you would need to add an additional LED that is hooked up to an unused pin, and change the code to use that pin instead of pin 13.

It is unfortunate, that pin 13 is used for both the LED and the default SPI SCLK pin. This is due to the fact that Paul tried to make the important pins on the Teensy 3.0 compatible with pins used by the Arduinio Uno and similar microprocessors that were dominant at the time. The UNO used pin 13 for both the LED and the SPI SCLK pins.

When the Teensy 3.1 came out, the internal microprocessor had to have the I2S pins on pin 11 and 13, and Paul had to build the audio shield that used the alternate SPI pins for MOSI and SCLK.

Then when the Teensy 4.0 came out, the I2S pins were on different pins, and re-mapping the SPI pins as used in the Teensy 3.x systems could not be done. This meant the audio shield revision D used the standard SPI pins (11, 12, 13).
 
Last edited:
Back
Top