Tag Archives: i2s

Linux kernel support for the HiFiBerry Mini

TuxI just wanted to start to develop a kernel module for the HiFiBerry Mini. But looking at the current code on Github, I noticed, that there is already a driver for the PCM5102A chipset now. This is great news, because it means that the HifiBerry Mini board is supported by the I2S-enabled kernel already. I will do some tests with RaspyFi in the next week to see, how this combination performs.

The kernel sources for the version with the included I2S driver can be found at https://github.com/koalo/linux

hifiberry-mini-proto-4-3Just a quick update: I did the first tests with HiFiBerry Mini – our high-resolution DAC for the Raspberry Pi. The card is working, sine waves look great on the oscilloscope. More tests have to be done. I will be interesting to see what will be the highest sample rate that I get running on the Raspberry – the DAC supports up to 384kHz!

HifiBerry Mini Prototyping starts

hifiberry-mini-proto1And there is the next Raspberry sound project – the HifiBerry Mini. This is a DAC for the Raspberry Pi, that is based on a PCM5102 from Texas Instruments. It has a The chip runs at 3.3V and used the 3.3V provided by the Raspberry Pi. Because this supply is quite noisy, it will be used only for the digital part of the chip. The analog output will be sourced by the TPS7A4901 – also from Texas Instruments. This is a high-end voltage regulator specifically designed for ultra-low-noise analog circuits.

This PCB is also a good device to practice SMD soldering. Both ICs comes in 0.65mm pin pitch. Almost all passive components are 0603 packages. But don’t be scared! You only need some magnifying glasses (I use 2.5x magnification), a good soldering iron and good solder paste (this is really important!). If you don’t believe me, check out the soldering tutorials that I linked here. There is no need for a reflow oven for this circuit.

Unfortunately all passive components are missing at the moment. They should arrive in the next days. Then I will be able to test the device. Stay tuned!

Connecting a Raspberry Pi and an ADAU1701 DSP

It looks like a simple task – connect the Raspberry Pi with an external ADAU1701 DSP chip. Both features an I2S interface – just connect it. However, it is not that easy. The ADAU1701 can only work as a slave device on the I2S input. Why not just using the Raspberry Pi as the master? This also won’t work, because the Raspberry Pi can create the BCLK and LRCLK signal, but not a 256xFs master clock signal that is needed by the ADAU1701. Using a local master clock on the ADAU1701 and the I2S clock from the Raspberry Pi will also not work, because both clocks have to be synchronous. Looks like a bit more complexity is needed.

We use the following setup: An external frequency generator creates the 12.288 MHz master clock and a synchronous 3.072 MHz BCLK signal. This BCLK signal will be the master clock for the I2S output of the Raspberry Pi. From this clock signal, the Raspberry Pi creates the 48 kHz LRCLK signal. Why are we not creating this clock externally? Because we have only a 2 channel signal generator available in the lab. This needs some tweaking in the sound card driver.

The ingredients of this test setup are

  • Rigol DG4062 signal generator
  • Raspberry Pi
  • MiniDSP (our own DSP board is not ready yet)
  • Lab power supply

For measurements I use a Rigol DS2072 DSO and a Intronix Logicport Logic analyzer. That’s a lot of equipment to connect two simple devices:

raspberry-dsp-tests

I had serious trouble to get this setup running. The reason for this was a simple mistake: I switched BCLK and LRCLK. But during debugging I had another idea. The output of the ADAU1701 is an I2S master. That means it can be used also as the master clock for the input. With this setup – output BCLK and LRCLK connected to input BCLK and LRCLK, there is no need for an external clock source. The ADAU1701 can create all the necessary clocks with the onboard resonator. This will simplify our DSP project a lot.

Finally when everything worked, it looked like this on the oscilloscope: a nice analog output from the ADAU1701.
adau1701-out

Improving signal quality on Raspberry Pi I2S data lines

In the previous experiments there was a lot of ringing on the I2S signal when connecting the Raspberry Pi to an external DAC. The signal frequency is not really high, about 3MHz. Why not having a resistor in the data line that helps damping the ringing. Look, what happens with a 220 Ohm resistor between the Raspberry and the DAC:

raspberry-overshoot_correction

In the picture you see the signal before (yellow) and after (blue) the resistor. You can see, that rise time increases from 3.5 ns to 8 ns. But this is still fast enough! And now the good news: Overshoot has been reduced from 25% to 5%. Much better! There should be no problem to increase the resistor even further up to 1 kOhm. But I think, the 220 Ohm resistor does the job.

Are you looking for a Raspberry Pi I2S sound interface? Check out our HiFiBerry Mini!

Adventures in I2S country

After getting I2S sound output running on the Raspberry Pi, I started communications with an ADAU1701. The chip has no sample rate converter (ASRC) integrated, therefore I had to configure the Raspberry Pi to output 48kHz I2S with BCLK=64*FS. I used the TDA1541A module, because it did exactly what I was looking for – at least at 44.1kHz.

raspberry_i2s-44

However, when I switched to 48kHz, the I2S output changed. What happend? At 48kHz, the I2S bit clock was only 32*FS, not 64*FS anymore. It looks like a feature of the driver. This needs further investigations. I might have to create a special driver, that only enables 48kHz with BCLK=64*FS.

raspberry_i2s-48

Update: I had a look in the driver code. Looks like there is a bug in the driver. I did a short hack to fix this temporarily, now it looks good:

raspberry_i2s-48-fixed

Unfortunately the ADC produces only noise. I have to investigate if there is a problem with the I2S data stream or if the signal quality is to poor to interpret the data correctly.

 

Raspberry Pi I2S output working

After some work and helpful web resources, one of our Raspberry Pi’s is now generating I2S signals.

DS2_QuickPrint1

You can see, that this is a 44.1kHz playback, the LRCLK frequency is 44.17kHz, the bit clock frequency is 2.778MHz which is about 64x LRCLK (almost, the frequency counter on the oscilloscope is not extremely accurate).

Having a look at the signal curves, you can see that there is a lot of noise and ringing on the signals. However, this is no problem, the voltages are never in the forbidden area.

DS2_QuickPrint2Another interesting question is: How much jitter do we see on both clock signals? Using the statistics functions on the oscilloscope (which are not the best method to measure jitter) we see a jitter on the clock signal of about 800 ps. On the lower frequency LRCLK, the jitter can’t be measured with my oscilloscope anymore. It is too low – which is a good sign for a high quality sound reproduction.

Many thanks to Koalo and  Noise if good for the helpful guide to compile a new kernel with I2S support.

Are you looking for a Raspberry Pi I2S sound interface? Check out our HiFiBerry Mini!

High resolution sound with the Raspberry Pi using I2S

raspberry-piOur HiFiBerry project is still ongoing. The PCB design is almost finalized and we expect the device to be ready in about 4-6 weeks. With HiFiBerry you will get an inexpensive and high-quality sound card for the Raspberry Pi. However, there is one thing it cannot provide: high-resolution sound, that means sampling frequencies above 48kHz are not supported. There are a lot of Pros and Cons for or against higher samples rates than 48kHz. At least when it comes to post processing like equalizing or digital crossovers, higher samples are a good idea.

You could also add an external USB sound card. But we are looking for a real DIY solution ;-) The 2nd revision of the Raspberry Pi provides access to the I2S pins of the processor. You can add an I2S capable ADC or DAC on these pins.

Unfortunately, the Linux kernel of the standard Raspberry Pi  does not support devices connected to the I2S pins. Therefore you need to compile your own kernel. Check out the “Noise is good” blog for more information. Hmm, looks like an interesting project for another Raspberry add-on board. We will have a look into this.