Simultaenous DAC and 2 channels of ADC

Status
Not open for further replies.

DrM

Well-known member
In a Teensy 3.2, I want to run the DAC and ADC to simultaneously output a waveform and read two channels of ADC, at rates up to 160 kHz if possible, or at the fastest rate at which the hardware can do this, with 16 bit resolution in the ADC.
(1) Can this done be done with DMA?
(2) Is there an example code, or API, that has this functionality?
(3) At a high level, what are the steps in software for doing this?
Thank you
 
The T3.2 DAC is 12-bits, and with proper wiring/environment you might get 13 accurate bits from the ADC. There are examples on the forum of using DMA (ping-pong buffer mgt with DMA done/half-done interrupt) and PDB timer to drive ADCs and DAC. One place to look is the teensy audio library
https://www.pjrc.com/teensy/td_libs_Audio.html

You can look at the library source code to see how the lib manages ADC, DAC, DMA , PDB ... Your first step might be to just use the audio library and the gui, http://www.pjrc.com/teensy/gui/index.html to configure 2 ADCs, a mixer,and DAC output. The library runs at 44khz, so later you could look at increasing that frequency. The DAC can only source 1 ma, so you need an amp if you are to drive a speaker.

There is an alternate ADC library with lots of options
https://github.com/pedvide/ADC
 
Thank you, I saw those. Where are the register names and bit masks defined? Do I have them automatically if I write my own code, or is there a header file that I need to include?

The gui tool looks very good. Is there a reason why it uses channels 2 and 3 only?

After the waveform i/o is completed, how do I regain access to the DAC and all of the ADCs for "single" calls for analog output and analog input?

I have buffers wired up for the output and inputs already. I was able to generate and read a 10kHz sine wave using analogWrite() and analogRead() in an ISR, and checked it with a scope.

Thank you
 
Status
Not open for further replies.
Back
Top