Adafruit UDA1334A Manual Download Page 5

For inputs, you can use classic I2S (the default) or 16-bit, 20-bit or 24-bit left justified data. You can set it up to take an

input system/master clock but we default-set it to just generate it for you, so you only need to connect Data In, Word

Select (Left/Right Clock) and Bit Clock lines. If you want, there's a mute pin and a de-emphasis filter you can turn on.

We put in plenty of ferrite beads, a low-dropout regulator, and the recommended band-pass filter so you get a very

nice clean output. 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

Summary of Contents for 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: ...audio if it s set Create asound conf file Add Device Tree Overlay Raspberry Pi Test Speaker Tests Simple white noise speaker test Simple WAV speaker test Simple MP3 speaker test Volume adjustment Pi...

Page 3: ...Adafruit Industries https learn adafruit com adafruit i2s stereo decoder uda1334a Page 3 of 45...

Page 4: ...rity 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 It s even cool with MCLK l...

Page 5: ...here s a mute pin and a de emphasis filter you can turn on We put in plenty of ferrite beads a low dropout regulator and the recommended band pass filter so you get a very nice clean output With a sin...

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: ...ns The UDA1334A requires 3 3V power but can take 3 5V level logic on nearly all pins You can provide 3 5V power on the VIN pin and GND and the built in regulator will generate a nice clean 3 3V suppli...

Page 8: ...o system AGND is a clean analog ground signal that we recommend using as your analog reference you ll get a cleaner signal Note that this DAC was intended for use with a separate amplifier and is rate...

Page 9: ...sis filter In video mode where the system clock is generated from an oscillator this is the clock output PLL sets the PLL mode by default pulled low for Audio Can be pulled high or set to 1 6V to set...

Page 10: ...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...

Page 11: ...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 adafru...

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: ...like the Pi Zero and is the easiest way to get quality audio out Connect 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 R...

Page 15: ...e 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 You don t need this on RetroPie because it never releases the I2S de...

Page 16: ...me after doing the speaker test with sudo reboot Once rebooted try running alsamixer and use arrow keys to lower the volume 50 is a good place to start If you re still having audio problems try re run...

Page 17: ...al console either via a console cable the TV console RXVT or what have you Edit the raspi blacklist with sudo nano etc modprobe d raspi blacklist conf If the file is empty just skip this step However...

Page 18: ...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 lea...

Page 19: ...nd 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 adafrui...

Page 20: ...period_size 1024 buffer_size 8192 rate 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...

Page 21: ...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 Indu...

Page 22: ...on the next line 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: ...hear audio coming from left and right alternating speakers Simple MP3 speaker test If you want to play a stream of music you can try sudo apt get install y mpg123 mpg123 http ice1 somafm com u80s 128...

Page 24: ...e 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 ad...

Page 25: ...e that the RaspPi I2S driver does not support dmixer by default and you must follow these instructions provided https adafru it sHF to add it Continue on for step by step on how to enable it Step 1 St...

Page 26: ...mmunication buffer is set up so there s no delays period_time 0 period_size 1024 and buffer_size 8192 work well The default mixed rate is 44 1khz stereo rate 44100 channels 2 Finally we set up a contr...

Page 27: ...he basic I2S chipset used here does not have software control built in So we have to trick the Pi into creating a software volume control Luckily its not hard once you know how to do it https adafru i...

Page 28: ...8192 rate 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 This...

Page 29: ...up right speaker test 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 t...

Page 30: ...wbq Run Demo Inside the zip is an example called pygameMP3 py This example will playback all MP3 s within the script s folder To demonstrate that you can also adjust the volume within pygame the seco...

Page 31: ...16 bit channels 2 1 is mono 2 is stereo buffer 2048 number of samples experiment to get right sound pg mixer init freq bitsize channels buffer if len sys argv 1 try user_volume float sys argv 1 except...

Page 32: ...pg mixer music stop raise 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: ...the install button Wiring Wiring connections are the same as those used for CircuitPython So go to the CircuitPython Wiring Test page to see how to wire the breakout for your specific board Basic Tes...

Page 34: ...1 Start with a low value to prevent damaging speakers define WAV_SIZE 256 The size of each generated waveform The larger the size the higher quality the signal A size of 256 is more than enough for th...

Page 35: ...buffer i amplitude 2 void playWave int32_t buffer uint16_t length float frequency float seconds Play back the provided waveform buffer for the specified amount of seconds First calculate how many samp...

Page 36: ...AV_SIZE generateSquare AMPLITUDE square WAV_SIZE void loop Serial println Sine wave for int i 0 i sizeof scale sizeof float i Play the note for a quarter of a second playWave sine WAV_SIZE scale i 0 2...

Page 37: ...status codes returned by some functions Adafruit_ZeroI2S i2s void dma_callback Adafruit_ZeroDMA dma we don t need to do anything here void setup Serial begin 115200 while Serial Wait for Serial monit...

Page 38: ...eg to here M4 else void I2S DATA 0 reg to here M0 endif BUFSIZE this many DMA_BEAT_SIZE_WORD bytes hword words true increment source addr false myDMA loop true Serial println Adding callback myDMA set...

Page 39: ...ot support I2S the last one is not a typo The M0 boards have multiple I2S pin combinations available We re going to demonstrate a single pin combination for each board Wiring The following wiring diag...

Page 40: ...the board 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...

Page 41: ...to D8 on the board Code Examples We have two CircuitPython code examples The first plays a generated tone through the audio jack on the breakout The second plays a wave file Let s take a look Tone Gen...

Page 42: ...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 i...

Page 43: ...e https adafru it BRj for pause and resume features Where s my I2S We mentioned earlier that the supported M0 boards have multiple I2S pin combinations available to you The M4 boards have one option E...

Page 44: ...stance pin Pin unique for p in pins if p not in unique unique append p return unique for bit_clock_pin in get_unique_pins for word_select_pin in get_unique_pins for data_pin in get_unique_pins if bit_...

Page 45: ...iles 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...

Reviews: