1
\$\begingroup\$

I am trying to design a Pi Hat to integrate my Raspberry Pi 3 for use as an automotive head unit. I have a Texas Instruments TAS6424 and some supporting components, and am trying to design a DAC PCB to drive the speakers.

Ignoring power issues etc, the issue I've run into is that the Raspberry Pi cannot output the mclk signal required by the TAS6424 chip's digital serial audio interface. The DAC operates in slave mode exclusively, while the Pi can operate in either master or slave mode on both the LRCLK and BCLK signals.

I've found the following devices that may be able to generate an appropriate signal.

Will this work to generate an external clock? Can the Pi generate a BCLK signal from a LRCLK? Vice versa? How much kernel modding will it take to properly control the above devices in order to switch sample rates at runtime and create a working ASoC device?

Developing something like this would allow one to interface the Pi with DACs that require a master clock signal, like most hifi i2s equipment.

\$\endgroup\$
1
\$\begingroup\$

For a delta sigma converter, MCLK is actually the critical one (It feeds the modulator), with the other two derived from it.

The common options are to use a PLL to derive this from LRCLK or (better) BCLK, or derive all three from a rock and divider chain (This usually gives the best quality, but you will need two rocks to accomodate the 44.1 and 48kHz derived rates unless you use a PLL like the 1708), in this case you run both interfaces in slave mode.

The PLL1708 plus a rock will get you an MCLK for all three possible rates, but you then need to divide this down to generate the serial and frame clocks, and you will need to run both sides of the interface in slave mode. Note that the LS294 is a 5V part!

\$\endgroup\$
  • \$\begingroup\$ When you say rock, you mean crystal, right? \$\endgroup\$ – Karthik Karyamapudi Jul 29 '17 at 14:40
  • \$\begingroup\$ Yea, slang around the office... Crystal or ceramic resonator or whatever. \$\endgroup\$ – Dan Mills Jul 29 '17 at 22:15
  • \$\begingroup\$ Okay, I was just making sure. I found a component that has a minimum voltage of 3v, but I'm not sure if I will need two, one for the word clock and one for the bit clock, or I'll need one and the Raspberry Pi can drive the other. \$\endgroup\$ – Karthik Karyamapudi Jul 29 '17 at 22:26
0
\$\begingroup\$

Think about it: MCLK is a clock used internally for the DAC; it gives you the sampling period. Now, if MCLK and SCLK drift away from each other, you end up in a situation where your DAC might be slower at converting samples to analog than your Pi is at sending them, and then what? Drop samples? Or conversely, it's faster, and then at some point internal FIFOs run empty and then what? Add 0 samples? repeat last samples?

So, the continuous MCLK must have a rational relationship to the "can stop in between" SCLK, on a average over a frame duration.

However, I'm totally not convinced you're right about the impossibility of just using the Pi's hardware to drive MCLK; that is a max 25 MHz clock, and the Pi's PWM units should be able to generate that. Use another timer to trigger sending N bits every N MCLK cycles. That way, in the time that the DAC converts one frame, you're sure that you're always sending one frame of data.

But: the raspberry pi comes with I²S hardware, so this might all be easier than you think. Just load the appropriate Kernel module (it's probably already there if you're using one of the major linux distros) and just use your DAC as sound card. Done.

Now, that I2S hardware on the Pi's SoC (read the datasheet!) won't be giving you a MCLK – I don't even know whether the TAS6242 actually needs that!

If it really needs that (and you're really set on having a DAC that needs a MCLK), then ok, by all means, use an external clock generator to generate both MCLK and SCLK; set the Pi's into I2S slave mode, and feed in the SCLK signal through some GPIO pin (18, I'd guess).

\$\endgroup\$
  • \$\begingroup\$ I haven't looked through the i2s drivers personally, but the lack of an mclock out is often listed as a restriction of the Pi, so I find it hard to believe that it can be driven by the Pi itself. I'll probably toss in a few solder jumpers or something so that I can try out that PWM timer method you mentioned. However, I don't think I made it clear, but the focus of my question was whether these particular components are suitable for this design and if the Pi can lock on to one of the clock signals and generate the other. This definitely helped clear stuff up though. \$\endgroup\$ – Karthik Karyamapudi Jul 29 '17 at 9:31
  • \$\begingroup\$ And the amplifiers datasheet strongly implies that an mclk signal is required for the chip to function. \$\endgroup\$ – Karthik Karyamapudi Jul 29 '17 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.