Home‎ > ‎Sergey's Blog‎ > ‎

Intel Edison - Simple I2S Audio Setup

posted May 21, 2015, 8:48 PM by Sergey Kiselev   [ updated May 21, 2015, 9:11 PM ]

Introduction

Intel Edison board provides I2S interface, and the recent firmware adds the I2S support. The default image provides two machine drivers: The default "dummy" driver simply outputs PCM data using I2S in DSP format, 24-bit, 48000 samples per second. The other machine driver is for the WM8958 codec, which appears to be a fairly complicated codec intended to be used in phones and tablets. The straight forward way to add support for another codec (say popular WM8731) is to write a machine driver for it. And I am currently working on it.
Meanwhile there is a simpler, but perhaps a bit more hackish way to get audio output working on Edison: by configuring the codec directly using I2C interface, and i2cset command in particular.

Hardware Setup

The following hardware is required:
  • Intel Edison board with a Mini Breakout board (Mouser: 607-EDI2BB.AL.K). Arduino breakout board might work as well, but it will require some modifications (and I haven't tested it yet).
  • Wolfson WM8731 codec based board like MikroElektronica Audion Codec Proto board (Mouser: 932-MIKROE-506). I used a board that I designed previously for Raspberry Pi Model B. Texas Instruments TLV320AIC23B codec appears to be compatible, and might work as well.
Connect the WM8731 codec to the Intel Edison board as indicated in the table below:
 Intel Edison Signal Name Pin number on Intel Edison Mini Breakout board Pin name on WM8731 Pin name on MicroElectronika Audio Codec Proto board  Comments
 I2C1_SDA (GP20) J17 - pin 8 SDIN SDA Data signal for the #1 I2C interface on Edison
 I2C1_SCL (GP19) J18 - pin 6 SCLK SCL Clock signal for the #1 I2C interface on Edison
 V_V1P80 J19 - pin 2 DBVDD, DCVDD 3.3V 1.8V power output from Edison. It is used to power WM8731 I/O and core.
 GND J19 - pin 3 DGND, AGND, CSB GND This is the ground rail. Connecting CSB to ground configures WM8731 in I2C mode. Some boards might already have it hooked up to the ground.
 SSP2_CLK (GP40) J19 - pin 10 BCLK SCL I2S clock signal
 SSP2_TXD (GP43) J19 - pin 11 DACDAT MOSI I2S transmit data output from Edison to codec
 V_V3P30 or V_VSYS J20 - pin 2 or J20 - pin 1 AVDD, HPVDD Connect directly to L2, cut trace going to 3.3V This is used as analog power supply. Ideally it should be an LDO on this signal. In my case I connected a 3.3V LDO to V_VSYS, and output of that LDO to the analog supply of the codec.
 SSP2_RXD (GP42) J20 - pin 9 ADCDAT MISO I2S receive data input from codec to Edison
 SSP2_FS (GP41) J20 - pin 10 DACLRC, ADCLRC DACLRC, ADCLRC I2S frame sync output

Note: It is likely that most codec breakout boards will have digital and analog power rails connected in some way (e.g. through an inductor based filter). In Edison's case digital I/O is 1.8V and so separate digital and analog supplies must be used. Modify your board accordingly. Note that maximal allowed analog supply voltage is 3.6V.

My Prototype Setup


Software Configuration

First of all Intel Edison board needs to be upgraded to the latest firmware image with I2S support (release 2.1 at the time of writing). The images and instructions are available from Intel at this page.
Connect the Intel Edison board with two micro USB cables to your PC, and run a terminal emulator (such as Putty on Windows or screen on Linux) and connect to USB-Serial port. Serial port settings are 115200 bps with 8 data bits and 1 stop bit, no parity. Login with user root, and run the i2cset commands below to configure the codec. Note that i2cset will return "Write failed" error if codec is not responding, e.g. if codec is not connected or powered properly.

I2C Configuration Script

#!/bin/sh

# reset codec
i2cset -y 1 0x1a 0x1e 0x00

# disable DAC and output powerdown
i2cset -y 1 0x1a 0x0c 0x07

# set volume for headphone output (both channels)
i2cset -y 1 0x1a 0x05 0x65

# analog audio path control (DAC enabled)
i2cset -y 1 0x1a 0x08 0x12

# digital audio path control
i2cset -y 1 0x1a 0x0a 0x00

# set sample rate (48000Hz, assuming 12.288MHz codec clock)
i2cset -y 1 0x1a 0x10 0x00

# digital audio interface format set (DSP mode, 24 bit)
i2cset -y 1 0x1a 0x0e 0x8b

# activate interface
i2cset -y 1 0x1a 0x12 0x01

Using the Audio Device

The codec is connected to ALSA device hw:1,0 . Refer to the software documentation on configuring the device name. For example in mpg123 player the audio device can be specified using -a switch:
mpg123 -a hw:1,0 -v "Dave Brubeck - Take Five.mp3"

AlexT's repository has several software packages that support audio output.

Output volume can be adjusted by writing headphone out register at address 0x05 (both channels) or 0x04 (left channel) and 0x06 (right channel), e.g.:
i2cset -y 1 0x1a 0x05 0x50

References



Comments