audio codec board

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Hello Michael,

The "audio proto codec board" from MikroE was supposed to serve as audio hub for many do-it-yourself digital audio projects, powered by microcontrollers like the PIC32 back in 2007 or 2008.

Unfortunately, when the "audio proto codec board" from MikroE went on the market, I guess in 2008 or in 2009, the PIC32 range was still in infancy, only providing unbuffered SPI or buffered SPI, but no SPI supporting the "audio mode" aka I2S.

As consequence, almost nobody could use such board. Many users complained about this. Many users wanted MikroE to publish source code, showing how to use such board in conjunction with existing PIC32 featuring unbuffered SPI or buffered SPI. In parallel, at the same moment, some users managed to emulate I2S on a buffered SPI, using the chip select as GPIO-driven frame-sync. I remember there was a workaround of limited use, for synchronizing the SPI on the frame-sync pin. From what I remember, this was only feasible in half-duplex. I had no interest for such workaround, as my application relied on full-duplex audio : sampling the audio coming from the WM8731 ADCs, processing it in digital domain, sending the processed audio to the WM8731 DACs.

A disturbing fact was the way MikroE labelled the pins. The pins are labelled like a plain normal SPI (MISO, MOSI, SCK), accompanied by pins labelled ADCLRCK and DACLRCK. This is mad, as this should be a plain normal I2S, featuring one frame-sync instead of two. This is indicating that such board was designed by people hoping to rely on some SPI workaround, for emulating a I2S.

Du to the fact that the WM8731 requires a I2C for configuring its internal registers, a lot of confusion came, from people confusing I2C with I2S.

Another disqualifying argument can be found in the way the designers exploited the WM8731 audio inputs and outputs.
The stereo line-in is not exploited. Instead you have a mono input on a stereo jack 3.5mm (as electret mike input) that's plagued by noise, and it outputs a DC polarization level.
The stereo line-out is not exploited. Instead, you have a stereo speakers output on a stereo jack 3.5 mm with 330µF AC-coupling capacitors.

The only positive aspect of the "audio proto codec board" from MikroE, is coming from the WM8731 architecture, forcing you to hook a crystal next to him, providing a high-quality audio master clock. The quartz being 12.288 MHz, it enables the HiFi 48 kHz sampling frequency.

Anyway, years after its introduction on the market, MikroE published some software, aiming at using their "audio proto codec board".
You may have a look here : LibStock - WM8731 - Example
Such software got written for the PIC32MX460F featuring unbuffered SPIs, and for the PIC32MX795F featuring buffered SPIs. Anyway, no "real" I2S.
I doubt their audio demo can work in full duplex.
I don't know if MikroE upgraded their demo software for supporting the latest PIC32 chips featuring the SPIs having the "audio mode" bit, kind of hardware-emulation of a I2S.

Anyway, today we are in July 2016.
There are ARM Cortex-M4 chips featuring SPI like the STM32F3 and F4 featuring I2S, and also STM32F7 chips equipped with TDM (multichannel evolution of I2S).
The Nucleo F401RE and Nucleo F411RE "starter kits" appear ideal to me, for hooking the "audio proto codec board" from MikroE.

The WM8731 is still supported by Cirrus Logic, after their purchase of Wolfson.
WM8731 : Codec with Headphone Driver
The WM8731 being a reasonably complicated chip, by paying attention to the datasheet you will know the registers you need to write for initializing it.
The datasheet is here : http://www.cirrus.com/en/pubs/proDatasheet/WM8731_v4.9.pdf

By the way, my drawers still contain a few "audio proto codec board" from MikroE, and a few Nucleo F401RE and Nucleo F411RE "starter kits", quite dusty now. If you intend working on this, I'll jump on the bandwagon.

I don't care about drivers and code re-usability. The main_loop is going to be nop codes. The WM8731 is going to interrupt the CPU at 48 kHz. For each of the two audio channels, the audio DSP is going to consist on eight IIR BiQuads plus one 32-tap FIR filter. The DSP will get executed each time there is a new audio sample (left right pair) available. There can be a flag scanned by the main_loop. It also can be the interrupt. Two GPIO will serve as output signals to be displayed on a scope, telling when the DSP gets executed, and how much time it takes. The audio DSP is so trivial, that it should be written in assembly code for being sure about every bit of the process. The whole code, including the initialization code, should list on less than two A4 pages. I don't care about the application being able to edit the IIR coefficients and FIR coefficients,as they will remain fixed, passed by the compiler, flashed in memory.

Having realized how poorly MikroE exploited the WM8731 input/outputs, I wanted to design a Nucleo "cape" hosting a WM8731, having a pair of RCA-in and a pair of RCA-out.

I then went across the WM8580, kind of WM8731 big brother featuring a SPDIF-in, a SPDIF-out, two audio channels as analog in, and six channels as analog out. I then wanted to design a Nucleo "cape" hosting a WM8580 having SPDIF-in, SPDIF-out, a pair of RCA-in and three pairs of RCA-out.
You may have a look here : WM8580 : codec with S/PDIF Transceiver

Speaking of an audio hub to be connected on a microcontroller using I2S, what do we have as ready-made alternatives ?
Answer : the WOLFSON AUDIO CARD for Raspberry Pi.
See here : https://be.farnell.com/fr-BE/wolfson-microelectronics/wolfson-audio-card/carte-raspberry-pi-soundcard/dp/2347264
Selling price : less than $25.
This is the audio hub originally developed by Wolfson and Element14, for the old Raspberry Pi featuring the 26-pin expansion connector along with the "P5" 8-pin digital audio header.
The Wolfson Audio Card embeds :
- one WM5102 Audio Codec featuring stereo audio in (analog) and stereo audio out (analog),
- one WM8804 SPDIF transceiver featuring SPDIF-in and SPDIF-out,
- two WM7720 Digital Siicon Microphones.
The difficulty with such arrangement, is to properly configure the WM5102 using I2C. Get warned : the WM5102 datasheet is 334 pages long.
Fortunately there is a Raspberry distribution supporting the Wolfson Audio Card.
This webpage provides a Raspberry Pi Image from Element14 that contains support for the Cirrus Logic audio card : https://www.adafruit.com/products/1761
Beware of the 2 Gigabytes to be downloaded. This is massive Linux stuff.
You would think that one may try locating the WM5102 initialization source code, and copy-paste it to a STM32F4 or STM32F7 application. I've tried this. It doesn't work because the 2 Gigabytes are "image" code, not "source" code.
The beauty of the WM5102 and WM8804, is that it gets supported by the Wolfson PC-based emulator & configurator. All you have to do is to (virtually) configure the WM5102 and WM8804 using a PC software. At the end of the session, you exploit the historic of the data written into the registers, for knowing what data your microcontroller needs to write over there. Easy as 1-2-3. I am presenting this in post 36-37-38 of the discussion here : http://www.diyaudio.com/forums/digital-line-level/293603-can-low-jitter-achieved-stm32-microcontroller-4.html

Regards,
Steph
 

Attachments

  • MikroE AUDIO CODEC PROTO.jpg
    MikroE AUDIO CODEC PROTO.jpg
    148.5 KB · Views: 164
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.