Adafruit UDA1334A Manual

Adafruit UDA1334A Manual

I2s stereo decoder

Advertisement

Adafruit I2S Stereo Decoder - UDA1334A
Created by lady ada
Last updated on 2019-01-30 06:56:56 PM UTC

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the UDA1334A and is the answer not in the manual?

Questions and answers

Summary of Contents for Adafruit UDA1334A

  • Page 1 Adafruit I2S Stereo Decoder - UDA1334A Created by lady ada Last updated on 2019-01-30 06:56:56 PM UTC...
  • Page 2: Table Of Contents

    Install PyGame Run Demo Arduino Wiring & Test Wiring Basic Test DMA Test CircuitPython Wiring & Test Wiring Code Examples Tone Generation Wave File Where's my I2S? Downloads Files Schematic & Fabrication Print © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 2 of 45...
  • Page 3 © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 3 of 45...
  • Page 4: Overview

    This fully-featured UDA1334A I2S Stereo DAC breakout is a perfect match for any I2S-output audio interface. It's affordable but sounds great! The NXP UDA1334A is a jack-of-all-I2S-trades: you can use 3.3V - 5V logic levels (a rarity), and can process multiple different formats by setting two pins to high or low. The DAC will process data immediately, and give you a clear, analog, stereo line level output.
  • Page 5 With a sine-wave generator we swept through 20-20KHz and saw no attenuation or distortion. Plug into either the 3.5mm stereo headphone jack or the breadboard-friendly pads. We think you'll be pleased with this DAC! © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 5 of 45...
  • Page 6 Each order comes with one I2S Stereo DAC breakout and some header you can solder on. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 6 of 45...
  • Page 7: Pinouts

    Pinouts The UDA1334A is an I2S amplifier - it does not use analog inputs, it only has digital audio input support! Don't confuse I2S with I2C, I2S is a sound protocol whereas I2C is for small amounts of data. Power Pins The UDA1334A requires 3.3V power but can take 3-5V...
  • Page 8: Audio Outputs

    Most of the pins have to do with changing the setup from audio mode to video mode. If you happen to want video- mode, for synchronizing with NTSC/PAL, check the datasheet - we haven't used it for that purpose. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a...
  • Page 9 SF0 and SF1 are used to set the input data format. By default both are pulled Low for I2S but you can change them around for alternate formats. See the back of the PCB for a quick reference © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 9 of 45...
  • Page 10: Assembly

    Installing Standard Headers The shield comes with 0.1" standard header. Break apart the 0.1" header into 6 and 9-pin long pieces and slip the short ends into the holes in the board © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 10 of 45...
  • Page 11 Make sure that all of the short parts of the header are sticking through the two sets of pads on either side of the board Solder each one of the pins into the board to make a secure connection © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 11 of 45...
  • Page 12 © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 12 of 45...
  • Page 13 That's it! Move on to next page for wiring information © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 13 of 45...
  • Page 14: Raspberry Pi Wiring

    Amp Vin to Raspbery Pi 3V or 5V Amp GND to Raspbery Pi GND Amp DIN to Raspbery Pi #21 Amp BCLK to Raspbery Pi #18 Amp LRCLK to Raspbery Pi #19 https://adafru.it/A9T https://adafru.it/A9T © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 14 of 45...
  • Page 15: Raspberry Pi Setup

    (https://adafru.it/nFy) Run the following from your Raspberry Pi with Internet connectivity: curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash We've added an extra helper systemd script that will play quiet audio when the I2S peripheral isn't in use. This removes popping when playback starts or stops. It uses a tiny amount of CPU time (on a Pi Zero, 5%, on a Pi 2 or 3 its negligible).
  • Page 16 If you're still having audio problems, try re-running the script and saying N (disable) the /dev/zero playback service You can then go to the next page on testing and optimizing your setup. Skip the rest of this page on Detailed © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 16 of 45...
  • Page 17: Detailed Install

    If the file is empty, just skip this step However, if you see the following lines: blacklist i2c-bcm2708 blacklist snd-soc-pcm512x blacklist snd-soc-wm8804 Update the lines by putting a # before each line © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 17 of 45...
  • Page 18: Disable Headphone Audio (If It's Set)

    Edit the raspi modules list with sudo nano /etc/modules If the file is empty, just skip this step However, if you see the following line: snd_bcm2835 Put a # in front of it © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 18 of 45...
  • Page 19: Create Asound.conf File

    Control-X Y <return> Create asound.conf file Edit the raspi modules list with sudo nano /etc/asound.conf This file ought to be blank! Copy and paste the following text into the file © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 19 of 45...
  • Page 20 44100 channels 2 ctl.dmixer { type hw card 0 pcm.softvol { type softvol slave.pcm "dmixer" control.name "PCM" control.card 0 ctl.softvol { type hw card 0 pcm.!default { type plug slave.pcm "softvol" © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 20 of 45...
  • Page 21: Add Device Tree Overlay

    Edit your Pi configuration file with sudo nano /boot/config.txt And scroll down to the bottom. If you see a line that says: dtparam=audio=on Disable it by putting a # in front. Then add: dtoverlay=hifiberry-dac dtoverlay=i2s-mmap © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 21 of 45...
  • Page 22 Save the file. Reboot your Pi with sudo reboot © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 22 of 45...
  • Page 23: Raspberry Pi Test

    Many programs like PyGame and Sonic Pi have volume control within the application. For other programs you can set the volume using the command line tool called alsamixer. Just type alsamixer in and then use the up/down arrows to set the volume. Press Escape once its set © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 23 of 45...
  • Page 24 In Raspbian PIXEL you can set the volume using the menu item control. If it has an X through it, try restarting the Pi (you have to restart twice after install to get PIXEL to recognize the volume control © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a...
  • Page 25: Pi I2S Tweaks

    Continue on for step-by-step on how to enable it! Step 1 Start by modify /boot/config.txt to add dtoverlay=i2s-mmap Run sudo nano /boot/config.txt and add the text to the bottom like so: Save and exit. Then change /etc/asound.conf to: © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 25 of 45...
  • Page 26 44100 channels 2 Finally we set up a control interface but it ended up working best to just put in the hardware device here - ctl.dmixer { type hw card 0 } © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 26 of 45...
  • Page 27: Add Software Volume Control

    Luckily, its not hard once you know how to do it (https://adafru.it/ydQ). Create a new audio config file in ~/.asoundrc with and inside put the following text: nano ~/.asoundrc © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 27 of 45...
  • Page 28 { type softvol slave.pcm "dmixer" control.name "PCM" control.card 0 ctl.softvol { type hw card 0 pcm.!default { type plug slave.pcm "softvol" This assumes you set up the dmixer for no-popping above! © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 28 of 45...
  • Page 29 -c2 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav Then you can type alsamixer to control the volume with the 'classic' alsa mixing interface Just press the up and down arrows to set the volume, and ESC to quit © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 29 of 45...
  • Page 30: Play Audio With Pygame

    (also mp3 files) using pygame tested with Python273/331 and pygame192 by vegaseat #code modified by James DeVito from here: https://www.daniweb.com/programming/software-development/code/454835/let-py #!/usr/bin/python import sys import pygame as pg import os import time © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 30 of 45...
  • Page 31 KeyboardInterrupt: # if user hits Ctrl/C then exit # (works only in console mode) pg.mixer.music.fadeout(1000) pg.mixer.music.stop() © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 31 of 45...
  • Page 32 SystemExit else: print("Please specify volume as a float! (0.0 - 1.0)") © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 32 of 45...
  • Page 33: Arduino Wiring & Test

    Basic Test To test things out, try running the demo below. It comes with the library installation, so you can find it by going to: File -> Examples -> Adafruit Zero I2S Library -> basic Be sure to change this line: Adafruit_ZeroI2S i2s(0, 1, 9, 2);...
  • Page 34 // Connect an I2S DAC or amp (like the UDA1334A) to the Arduino Zero // and play back simple sine, sawtooth, triangle, and square waves. // Makes your Zero sound like a NES! // NOTE: The I2S signal generated by the Zero does NOT have a MCLK / // master clock signal.
  • Page 35 // It appears the order is right channel, left channel if you want to write // stereo sound. i2s.write(sample, sample); void setup() { // Configure serial port. Serial.begin(115200); Serial.println("Zero I2S Audio Tone Generator"); // Initialize the I2S transmitter. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 35 of 45...
  • Page 36: Dma Test

    It can then take care of generating the output in the background allowing you to do other things in your code. To take this approach, you will need to install the Zero DMA library (https://adafru.it/lnb). You can do that through the Library Manager: © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 36 of 45...
  • Page 37 And then you can use the DMA example found in the Zero I2S library: File -> Examples -> Adafruit Zero I2S Library -> dma #include <Adafruit_ZeroI2S.h> #include <Adafruit_ZeroDMA.h> #include "utility/dma.h" #include <math.h> /* max volume for 32 bit data */ #define VOLUME ( (1UL <<...
  • Page 38 /* begin I2S on the default pins. 24 bit depth at * 44100 samples per second i2s.begin(I2S_32_BIT, 44100); i2s.enableTx(); stat = myDMA.startJob(); void loop() Serial.println("do other things here while your DMA runs in the background."); delay(2000); © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 38 of 45...
  • Page 39: Circuitpython Wiring & Test

    VIN is the red wire. GND is the black wire. BCLK is the blue wire. WSEL is the yellow wire. DIN is the green wire. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 39 of 45...
  • Page 40 Connect GND on the breakout to G/GND on the board. Connect BCLK on the breakout to D1/TX on the board. Connect WSEL on the breakout to D0/RX on the board. Connect DIN on the breakout to D9 on the board. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 40 of 45...
  • Page 41: Code Examples

    The first example generates one period of a sine wave and then loops it to generate a tone. You can change the volume and the Hz of the tone by changing the associated variables. Inside the loop, we play the tone for one second and stop it for one second. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 41 of 45...
  • Page 42: Wave File

    The second example plays a wave file. We open the file in a readable format. Then inside the loop, we play the file and tell the code to continue playing the file until it's completed. You can use any supported wave file (https://adafru.it/BRj). We've included the wave file used in the code. https://adafru.it/BTM https://adafru.it/BTM © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 42 of 45...
  • Page 43: Where's My I2S

    Either way, if you'd like to know what options are available to you, copy the following code into your code.py, connect to the serial console, and check out the output. These are the results from the ItsyBitsy M0 Express. © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 43 of 45...
  • Page 44 "\t Word select pin:", word_select_pin, "\t Data pin:", data_pin) else: pass © Adafruit Industries https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a Page 44 of 45...
  • Page 45: Downloads

    Downloads Files EagleCAD PCB Files (https://adafru.it/BtN) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) UDA1334A Datasheet (https://adafru.it/BtO) Schematic & Fabrication Print © Adafruit Industries Last Updated: 2019-01-30 06:56:54 PM UTC Page 45 of 45...

Table of Contents