Changing I2C clock frequency on teensy and DAC

Status
Not open for further replies.

CCC

New member
Good day Everyone.

I have a Teensy 3.2 and a DAC8574 and I wish to do a frequency sweep with a constant amplitude to characterize a transistor.

Does someone know how to change the frequency of the DAC with software so that I can run a frequency sweep and therefore generate an AC signal from the DAC? Or should I change the clock frequency of the Teensy? however that is the rate of communication (so ideally would not want to change that).

It does not help to post my code as I only have code to generate a constant voltage from the DAC, however if you require that from me I can post it.

Thank you.
 
To get an AC signal from your DAC, you'll need a blocking capacitor to get rid of the DC component and you'll get +/- signal.
See https://forum.pjrc.com/threads/28581-Connecting-a-Speaker-to-Teensy-3-1-DAC-A14
if you are thinking of driving speakers, consider the Teensy Audio Adaptor and the onboard DACs of Teensy 3.5/3.6

Looking at the DAC8574 data sheet, your max square wave frequency will be limited by the I2C clock. For a 12-bit or 16-bit DAC value you'll have to send two I2C data bytes for each DAC setting. The i2c_t3 library will probably give you the best I2C performance and has some graphs showing I2C speed.
see https://github.com/nox771/i2c_t3
You can change I2C clock speed with Wire.setClock(), but the hardware only supports a discrete set of I2C clock speeds. You can slow your DAC update rate with delayMicroseconds() or Teensy interval timer. The teensy audio lib supports various transforms for sweeping through audio frequencies.

A quick calculation would show that with I2C clock at 400KHz, the highest frequency square wave for your DAC8574 would be about 11KHz (400/36), actual rate more like 9KHz.
 
Last edited:
Status
Not open for further replies.
Back
Top