commonbreed
Member
I'm looking at the DAC output on my scope and it looks janky.
I'm using the audio library to run a sine wave at 5kHz:
... but the scope is only showing about 9 level transitions per cycle. Using the scope's cursor, I can see that the level is updating about once every 23 microseconds. According to the chip's datasheet, the code-to-code settling time should be no longer than 1 microsecond (I know this isn't code-to-code, but it's pretty close). What am I doing wrong? I thought the DAC should be able to handle "audio-range" outputs quite happily but I'm failing down in the couple-of-kHz range.
EDIT: I've just seen and tested the Hackaday article which runs the DAC at 100kHz using DMA, and it works a treat. Does the Audio library not use DMA?
I'm using the audio library to run a sine wave at 5kHz:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
static int freq = 440;
static int dir = 0;
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=220,160
AudioOutputAnalog dac1; //xy=472,158
AudioConnection patchCord1(waveform1, dac1);
// GUItool: end automatically generated code
void setup() {
analogWriteResolution(12);
AudioMemory(10);
waveform1.frequency(5000);
waveform1.amplitude(1.0);
waveform1.begin(WAVEFORM_SINE);
}
void loop() {
}
... but the scope is only showing about 9 level transitions per cycle. Using the scope's cursor, I can see that the level is updating about once every 23 microseconds. According to the chip's datasheet, the code-to-code settling time should be no longer than 1 microsecond (I know this isn't code-to-code, but it's pretty close). What am I doing wrong? I thought the DAC should be able to handle "audio-range" outputs quite happily but I'm failing down in the couple-of-kHz range.
EDIT: I've just seen and tested the Hackaday article which runs the DAC at 100kHz using DMA, and it works a treat. Does the Audio library not use DMA?