View Full Version : Teensy3 DAC - Anyone got I2C setup yet?

11-07-2012, 05:59 AM
Hey All,

Just to say hi and to share my excitement with the potential Teensy3 has to offer to audio geeks.

I've been programming some fun dsp stuff in openframeworks (mainly for iphone) and can't wait to port it to teensy.

I ordered this DAC from Mouser part#932-MIKROE-506 on Paul's recommendation.


Curious if anyone has tried I2C yet as I'm hoping to give it a try this weekend.

Thanks in advance for any hints!


11-07-2012, 01:16 PM
Curious if anyone has tried I2C yet
I have the precision DS3231 RTC and the Adafruit 2 x 16 LCD with tac switches working with the Teensy 3 100Khz I2C. (wire.h);)

11-07-2012, 01:47 PM
Several people (including myself) report success using i2c displays (after the supporting libraries have been fixed).

11-13-2012, 04:16 AM
Hi, Sorry to bump the thread again. I tried all weekend getting the DAC to work but I'm afraid I don't really know what I'm doing. I have the SDA and SCL (pins 18 and 19) hooked up to the SDA and DCL pins of the DAC board and GND and 3.3v.

Then I've been trying the WIRE/master_writer sketch to send data to it, but not getting any sound.

I'm assuming that I need to set up a timed interrupt for things to sound right but was counting on hearing some kind of noise just by sending random data in the main loop.

Here's the datasheet for the DAC board:

Perhaps someone could give me a hint to how to get it working. Should I connect anything in addition to the I2C?
I would be ever so greatful

Thanks for any tips!



Here is the sketch I've been playing with:

#include <Wire.h>

void setup()
Wire.begin(); // join i2c bus (address optional for master)

byte x = 0;

void loop()
Wire.beginTransmission(4); // transmit to device #4 - also tried devices 0-3
Wire.write(random(255)); // sends random data
Wire.endTransmission(); // stop transmitting


11-13-2012, 07:25 AM
One possibility: I2C is a shared bus which requires pullup resistors, for example 4.7 k to Vcc because the outputs are open-collector type (both SCL and SDA lines stay at 0 V without the pullups). You can have the pullup resistors on the CPU side, or the device side, or in between but they have to be there.

EDIT: nevermind, the schematic you linked to shows the DAC board does provide 1k pullups on SDA and SCL. Have you checked that the 3.3V supply is what you think it is? I don't know how much current the DAC board needs, maybe the voltage is getting loaded down?

EDIT 2: Looks like that board actually uses the 3-wire SPI interface (MISO, MOSI, SCK) to transfer audio data. The 2-wire I2C interface is only for a control channel (setting up internal registers). You need an actual datasheet to use the part, the brochure you linked to does not provide the programming and setup info.

11-13-2012, 09:03 AM
Hi JBeale,

Thanks for your notes, it turns out that there is already an arduino library for the wm8731 used on the board, audioCodecShield (http://wiki.openmusiclabs.com/wiki/AudioCodecShield) so that should keep me out of trouble for a while!

I'll try to get it running on the arduino first then see how it ports to teensy
Exciting stuff!


11-13-2012, 11:06 PM
I haven't touched audio stuff yet, despite how much I really want to play with audio. I'm still working on USB types and the major Arduino libraries (like OneWire, Encoder, etc). I did USB Keyboard and ported Servo recently and I'm working on the "Serial" emulation today, which lets the Arduino Serial Monitor work when non-serial USB types are used... and I'm hoping to get that wrapped up soon because I really need to publish "beta8" with Bill's fix for the heap/static conflict. Realistically, I'm going to be working on USB support and important Arduino libraries for at least a few more weeks.

A quick mention of I2S is probably worthwhile. Even though that board has SPI-like signal names, the I2C peripheral on the chip is the one to used for sending and receiving the audio data. SPI is similar and might be usable for audio, but I2S is designed for specifically for audio. Like most codecs, both I2C is also used. Even though these 2 protocols have similar names, differing only by "C" vs "S", they are in fact completely different.

I2C is for configuration and infrequent control messages. I2S is for continuously streaming audio.

01-14-2013, 10:32 PM
Alex - I don't know whether you had any luck having the audioCodecShield library talk to the codec control interface.

Meanwhile, here's my own contribution. A couple major caveats: [a] only implements the control interface (I2C), not the audio data interface; and [b] untested, experimental, and I don't actually know whether it works properly. Because (duh) i haven't yet put audio through the analog inputs or the digital data line. But I'll be doing that over the next couple weeks as time permits, and I'm pretty sure it'll work eventually.