Hello everyone, first post here.
I happen to own both a 3.6 and an FRDMK66F board, and found that they both use the same SD card pinouts.
I immediately thought: "Play WAV files on the FRDM's DAC pins to see what it does".
I proceeded to edit the WavFilePlayer sketch to read from the FRDM's SD card slot, and was left with a pleasant surprise upon upload. The song playback is much slower than on the 3.6, much to my amusement and dismay. I am not very experienced with schematics and chip initialization, but I have a hunch that the clocks are configured differently on this board. Any tips on dealing with this?
Arduino Version: 1.8.9
Teensyduino Version: 1.48
Upload Method: J-Link OpenSDA from exported binary
OS: Linux Mint 19.1
I happen to own both a 3.6 and an FRDMK66F board, and found that they both use the same SD card pinouts.
I immediately thought: "Play WAV files on the FRDM's DAC pins to see what it does".
I proceeded to edit the WavFilePlayer sketch to read from the FRDM's SD card slot, and was left with a pleasant surprise upon upload. The song playback is much slower than on the 3.6, much to my amusement and dismay. I am not very experienced with schematics and chip initialization, but I have a hunch that the clocks are configured differently on this board. Any tips on dealing with this?
Arduino Version: 1.8.9
Teensyduino Version: 1.48
Upload Method: J-Link OpenSDA from exported binary
OS: Linux Mint 19.1
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
//
// 2: Digital S/PDIF - Connect pin 22 to a S/PDIF transmitter
// https://www.oshpark.com/shared_projects/KcDBKHta
//
// 3: Analog DAC - Connect the DAC pin to an amplified speaker
// http://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog
//
// 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.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// PLayback
AudioPlaySdWav playWav1;
AudioOutputAnalogStereo audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
// 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(50);
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 playFile(const char *filename)
{
Serial.print("Playing file: ");
Serial.println(filename);
// Start playing the file. This sketch continues to
// run while the file plays.
playWav1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
while (playWav1.isPlaying()) {
}
}
void loop() {
playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format
}