h4yn0nnym0u5e
Well-known member
Excellent news, glad we got it sorted out. It’s prompted me to improve the documentation for the PR branch (it shows up in the Design Tool), so once it’s in, things should be a bit easier for everyone.
I was thinking in terms of having the option to use different pins as chip select. D2-4 are also I2S2, so might well be wanted for an audio project. There aren’t many pins on a Teensy 4.0 that can’t be used for some audio function or another, but a 4.1 gives a few more options.Can you please clarify "links to change the device selection lines." Is this just a naming thing, like I should use C0/C1/C2 instead of DO2/DO3/DO4? If so, I agree. Or are you talking about moving to different pins altogether?
Once this comes together, I will post on github and run a few copies with Osh Park.
Great, thanks. One point that’s just occurred to me … as it is there’s always one PSRAM enabled, so the SPI bus can’t be used for anything else. That wasn’t an issue with only 6 of them, of course, as there are a couple of unused addresses.
why Frank put the 74LCX126 on memoryboard4. Can/should it be removed to allow two more memory chips on a new board?
I did wonder about that part…The 74LCX126 is for level shifting, because Teensy3 is 5V, the memory chips are not. It's not needed for Teensy4.
I am building a memory expansion board that's shorter so it fits on Teensy 4.0 footprint (also 4.1 of course) and has (6) 23LC1024 chips. It uses the same memory addressing scheme as the original Teensy 3 Memoryboard so hopefully it'll be recognized by the libraries.
#include "Arduino.h"
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#define DUMMY_TIME_MS 92700.0f
// GUItool: begin automatically generated code
AudioSynthWaveformModulated waveformMod; //xy=183,174
// One PSRAM 8MB chip is 95108.93ms of delay
// With a SPI bus of 31.41MHz, and 3 delay objects with 3, 3, and 1 tap, we
// need to do 3 writes and 7 reads of 128*2*8 = 2048 bits, so 20480 bits,
// which will take about 0.68ms. This happes every 2.9ms, so expect
// a CPU load of 22.4%. We get about 19%, so fairly close.
AudioEffectDelayExternal delayExt(AUDIO_MEMORY_PSRAM64_X8, 1400.0f); //xy=322,396
AudioEffectDelayExternal dummyDelay(AUDIO_MEMORY_PSRAM64_X8,DUMMY_TIME_MS); // make next delay cross chip boundary
AudioEffectDelayExternal delayExt1(AUDIO_MEMORY_PSRAM64_X8,2000.0f); //xy=329,641
AudioMixer4 mixer4; //xy=604,213
AudioMixer4 mixer5; //xy=611,458
AudioOutputI2S i2s; //xy=811,148
AudioConnection patchCord1(waveformMod, 0, mixer4, 0);
AudioConnection patchCord2(delayExt, 0, mixer4, 1);
AudioConnection patchCord3(delayExt, 1, mixer4, 2);
AudioConnection patchCord4(delayExt, 1, mixer5, 0);
AudioConnection patchCord5(delayExt, 2, mixer4, 3);
AudioConnection patchCord6(delayExt1, 0, mixer5, 1);
AudioConnection patchCord7(delayExt1, 1, mixer5, 2);
AudioConnection patchCord8(delayExt1, 2, mixer5, 3);
AudioConnection patchCord9(mixer4, delayExt);
AudioConnection patchCord10(mixer4, 0, i2s, 1);
AudioConnection patchCord11(mixer5, delayExt1);
AudioConnection patchCord12(mixer5, 0, i2s, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=811,195
// GUItool: end automatically generated code
void setup() {
Serial.begin(115200);
Serial.println("Starting audio...");
AudioMemory(40);
mixer4.gain(0,0.71f);
mixer4.gain(1,0.05f);
mixer4.gain(2,0.20f);
mixer4.gain(3,0.71f);
Serial.println("Set up delayExt object");
delayExt.delay(0,23.0);
delayExt.delay(1,137.0);
delayExt.delay(2,911.0);
mixer5.gain(0,0.71f);
mixer5.gain(1,0.05f);
mixer5.gain(2,0.20f);
mixer5.gain(3,0.71f);
Serial.println("Set up delayExt1 object");
delayExt1.delay(0,29.0);
delayExt1.delay(1,241.0);
delayExt1.delay(2,1297.0);
Serial.println("Set up dummyDelay object");
uint32_t now = micros();
dummyDelay.delay(0,29.0);
now = micros() - now;
float SPIrate = DUMMY_TIME_MS / 1000.0f * AUDIO_SAMPLE_RATE * 2 * 8 / now;
Serial.printf("SPI bus speed = %.2fMHz\n",SPIrate);
Serial.printf("Maximum delay is %.3fms\n",delayExt.getMaxDelay());
int x = sizeof(((audio_block_t*) 0)->data[0]);
Serial.printf("Sample size is %d bytes\n",x);
sgtl5000_1.enable();
sgtl5000_1.volume(0.2);
sgtl5000_1.lineOutLevel(14); // 2.98V pk-pk
}
uint32_t next;
void loop() {
if (millis() > next)
{
next += 5000;
waveformMod.begin(1.0f,220.0f,WAVEFORM_SINE);
delay(10);
Serial.printf("Usage %.2f, max %.2f\n",AudioProcessorUsage(),AudioProcessorUsageMax());
AudioProcessorUsageMaxReset();
waveformMod.amplitude(0.0f);
}
}