Custom i2s in with simultaneous S/PDIF & USB out

Technical questions regarding the XTC tools and programming with XMOS.
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

infiniteimprobability wrote: I think you may need to cut a track to get MCLK off the line. Cut it at the input to the NC7SZ157 mux so it works as a buffer to all of the MCLK recipiants (it needs to go to both tiles on the XMOS chip)..You'll also get better signal integrity as it uses series resistors to match the impedance and reduce reflections.
Okay, so you mean chip U12? I see being a mux both pins 1 and 3 are inputs. Which do I cut and tied to my external MCLK source?

Just to clarify I take it you mean these lines I've highlighted in green:

Image

Thanks again


yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

Okay I solved MCLK without cutting any tracks

I carefully soldered a small wire to pin 6 of the mux which is the select pin, then soldered a male jumper to one of the 3.3v headers on the board. Now I can pull that wire high and low just by pulling it on and off the header.

This switches the input of the MUX from the permanent PL611 local clock to the CS2100 clock, which in the reference design appears to be inactive and not dishing out any clock signal. voila the rest of the MCLK is now quiet.

I could plug my external clock into the MUX like you said but for test purposes I'll try plugging directly into the MCLK header on the PCB first.

:)
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Good idea - I didn't consider that the PLL could disable the output. A neat workaround without any track cutting, although personally I'm happy to hack up boards with the scalpel. Thats the benefit of having a ready of supply of them :)
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

haha yes, at over 200 quid a pop I'll only cut if I have to.

Direct plug to MCLK cause my external signal to dive to less than a volt so that won't work. Somehow it's pulled low.

I will next input my MCLK to the input mux pin, if it still pulls low I may need to cut a track to disconnect the PLL from the mux incase the PLL is pulling it down.

cheers!
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

Okay so the output pin from the PLL was pulling my MCLK down so I had to cut a track! heh, it worked though. Also by adding the mux switch I can easily switch back to the permanent MCLK that comes with the standard reference design. The PLL and mux pins are so close that I can easily bridge them with wire if I need to reinstate that track so it's all good :)

now to see if it likes my I2s input!
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

Hallelujah! My I2s source is now coming into the PC via the XMOS board and it's AUDIBLE!!!

Get some strange artfacts when moving the mclk wire around and there's some occasional crackle but this it a 12MHz signal floating along a cheap breadboard wire and I've had MCLKs cause problems doing this before. It should be fine on a PCB.

So, set XMOS as slave, silenced the ADC using i2c, silenced MCLK by switching the Mux and cutting a track into it. Now I just need to get this signal coming out on SPDIF independently.

You say to add the following, can you tell me where I need to do this? THANKS!


outuint(c_spd_out, samplesIn[0]); /* Forward left sample to S/PDIF Tx thread */
outuint(c_spd_out, samplesIn[1]); /* Forward right sample to S/PDIF Tx thread */
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Good work on getting audio working. I have found that flying leads for I2S can work, but can be the cause of noise. Sometimes even grabbing the lead (adds a tiny amount of capacitance) can fix any noise issues.. Also adding a series resistor at the source of the signal helps when on the PCB (like MCLK buffer).
can you tell me where I need to do this?
Yes - replace the outuints below.. Or, thinking about it, just set SPDIF_TX_INDEX to 0...

Code: Select all

#if defined(SPDIF_TX) && (NUM_USB_CHAN_OUT > 0)
            outuint(c_spd_out, samplesOut[SPDIF_TX_INDEX]);  /* Forward sample to S/PDIF Tx thread */
            unsigned sample = samplesOut[SPDIF_TX_INDEX + 1];
            outuint(c_spd_out, sample);                      /* Forward sample to S/PDIF Tx thread */
#endif
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

I set the index to 0 and also restricted the USB and DAC ADC channels to 2 as that's all I need.

When I play audio from the PC to XMOS I see audio come out on the SPDIF Tx plug.

However what I want is the SPDIF to permanently output what's coming in on the I2s input line, iADC_SD1 I believe? Even when the USB plug is not connected to the PC.

So far I've done the following:

Set USB and I2s channel count to 2
set SPDIF index to 0 (was 8)
Set max samplerate to 48000
set MCLK to 256xfs
set codec master to 1
cut a track for the MCLK

Everything is working apart from SPDIF needs to send out my I2s signal at all times.

Is there another edit I need to make?

Thanks!!
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

However what I want is the SPDIF to permanently output what's coming in on the I2s input line, iADC_SD1 I believe? Even when the USB plug is not connected to the PC.
Doh - brain not on following Christmas holiday...

Replace with

Code: Select all

outuint(c_spd_out, samplesIn[0]); /* Forward left sample to S/PDIF Tx thread */
outuint(c_spd_out, samplesIn[1]); /* Forward right sample to S/PDIF Tx thread */
as previously suggested when brain was working..
I2S free runs even with no host connected so this should work.
yes2i2s
Experienced Member
Posts: 73
Joined: Tue Nov 24, 2015 4:06 pm

Post by yes2i2s »

I change this:

outuint(c_spd_out, samplesOut[SPDIF_TX_INDEX]); /* Forward sample to S/PDIF Tx thread */
unsigned sample = samplesOut[SPDIF_TX_INDEX + 1];
outuint(c_spd_out, sample); /* Forward sample to S/PDIF Tx thread */


For this:

outuint(c_spd_out, samplesIn[0]); /* Forward left sample to S/PDIF Tx thread */
outuint(c_spd_out, samplesIn[1]); /* Forward right sample to S/PDIF Tx thread */


And get this build error:

module_usb_audio/audio.xc:702:32: error: use of undeclared identifer `samplesIn'
outuint(c_spd_out, samplesIn[0]); /* Forward left sample to S/PDIF Tx thread */


Any ideas?