// by default the Teensy 3.1 DAC uses 3.3Vp-p output
// if your 3.3V power has noise, switching to the
// internal 1.2V reference can give you a clean signal
//dac.analogReference(INTERNAL);
SIM_SCGC2 |= SIM_SCGC2_DAC0;
DAC0_C0 = DAC_C0_DACEN; // 1.2V VDDA is DACREF_2
// slowly ramp up to DC voltage, approx 1/4 second
for (int16_t i=0; i<2048; i+=8) {
*(int16_t *)&(DAC0_DAT0L) = i;
delay(1);
}
void AudioOutputAnalog::analogReference(int ref)
{
// TODO: this should ramp gradually to the new DC level
if (ref == INTERNAL) {
DAC0_C0 &= ~DAC_C0_DACRFS; // 1.2V
} else {
DAC0_C0 |= DAC_C0_DACRFS; // 3.3V
}
}
Nantonos, wouldn't the line out level method only change the output level if the audio board was being used? It doesn't seem logical for it to change the DAC output level.
Hi KurtAgain thanks,
I was wondering about having decoupling capacitor... The spec sheet did not show one, but I have a tendency to put one in for each IC on GP.
I did as you suggested and put one in for that as well as put two in series to make up the .05 (thanks I forgot about that from my old circuit analyzes class that I took a few decades ago...
The speaker is not generating a lot of sound yet, but I think I can fix some of this with changing back to larger resistor...
View attachment 4327
As you can se the signal is looking a lot nicer now!
Thanks again.