Close
0%
0%

Raspberry Pi TOSLINK transceiver hat

Optical digital audio I/O for Raspberry Pi

Similar projects worth following
Starting from
$40.00
nsayer has 1960 orders / 155reviews
Ships from United States of America
The Raspberry Pi has support for i2s audio I/O. It's fairly simple to add a S/PDIF transceiver chip and optical audio I/O ports on a hat to allow it to be conveniently used.

The WM8804 is the S/PDIF transceiver chip of choice for this project. Adding a single line to the Pi's config.txt file, to wit:

dtoverlay=hifiberry-digi

is enough to add support for it.

To be compatible with the driver, the chip needs to be configured in software controlled mode, i2c interfacing, the address has to be 0x3b. This is accomplished with pull-up or pull-down resistors on some of the I/O pins of the WM8804. For the driver, there also needs to be a 27 MHz crystal connected. The i2s I/O pins are connected to the relevant pins on the Pi, and the S/PDIF input and output pins connect to TOSLINK input and output modules.

The result of adding the WM8804 chip to the Pi is that it actually becomes the i2s bus master for clocking purposes. This dramatically improves the i2s timing fidelity, as when the Pi is the i2s clock master it winds up generating a lot of jitter because i2s clock frequencies don't divide evenly from the Pi's master clock source.

Of course, instead of optical I/O, you can add the WM8804 chip for timing and hook the i2s bus up to a high quality i2s DAC, like the PCM1793. Personally, I already have a high quality TOSLINK DAC project, which has the benefit of being totally electrically isolated from the Pi.

Adobe Portable Document Format - 47.84 kB - 11/16/2021 at 20:04

Preview
Download

brd - 55.68 kB - 11/16/2021 at 20:02

Download

sch - 139.59 kB - 11/16/2021 at 20:02

See BOM
Download

  • A required mixer setting

    Nick Sayer11/18/2021 at 06:24 0 comments

    Note that to get the output to work, you have to set the TX source to "AIF" - that is, you have to configure the chip to generate the TX output from the i2s input on the chip. You can do this in amixer by using cset to set the "Tx Source" control to whichever value (probably 1) that decodes to "AIF". The default is "S/PDIF RX", which means that it comes from the receive input, but that will only work if the i2s clocks happen to match up with the S/PDIF received signal.

    If you don't do this, then playing audio won't light up the output receptacle (which means it just won't work).

    You don't need to do this for recording - it always sends the S/PDIF receiver input to the i2s receive pin. But you must insure that the parameters for the reception actually match up with the input source.

View project log

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates