xcore-200 mc audio: How to switch between different sources

New to XMOS and XCore? Get started here.
alexjaw
Member++
Posts: 20
Joined: Wed Jan 24, 2018 9:13 am

xcore-200 mc audio: How to switch between different sources

Postby alexjaw » Tue Feb 06, 2018 11:21 am

I'm trying to understand how to configure the application app_usb_aud_xk_216_mc. I have read the USB Audio Design Guide but must have missed something essential. I can successfully run the various build configurations defined in the Makefile, but they do not behave as I would expect. USB is working as expected, but not SPDIF (as far as I have tested). The configuration 2i10o10xssxxx is supposed to activate SPDIF RX and TX. However, when I build and run this configuration, LRCLK always locks to 44100 kHz, even when USB is disconnected and I have a SPDIF in at 48000 KHz. I would expect that AudioHwConfig() in audiohw.xc should detect change in the sample rate, am I wrong? I also wonder the meaning of the following defines in customdefines.h:

#define NUM_USB_CHAN_OUT (10) /* Host to Device */
#define I2S_CHANS_DAC (8)
#define SPDIF_RX_INDEX (8)

- Does it say that USB audio from host is distributed to 10 channels?
- I2S to DAC is 8 channels?
- What would be the difference with: define SPDIF_RX_INDEX (0)?
User avatar
infiniteimprobability
XCore Expert
Posts: 1014
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Fri Feb 09, 2018 8:58 am

audiohw.xc should detect change in the sample rate, am I wrong?

Not quite - it will detect a change in the status of the clock validity. It uses an interrupt endpoint to notify the host to check validity of the clock. If there is no valid SPDIF rx stream then that will report invalid and it will switch to the internal clock (which is always valid).
The device cannot change the rate itself - it's USB so the host is always the master. The clock rate is selected by the host and it is assumed that the SPDIF input rate is the same.
I am not sure if it's possible to set up an interrupt to get the host to re-read the supported sample rate ranges and get the host to act accordingly. Feels like a bit of a sledghammer approach.. Maybe it's more sensible to enhance the validity check to check that it is a valid range AND matches the current selected frequency. (static inline int validSamples(Counter &counter, int clockIndex))

- Does it say that USB audio from host is distributed to 10 channels?

Yes - there are 10 audio channels between host and USB device.
- I2S to DAC is 8 channels?

Yes and the index is zero. i.e. the first 8 channels coming out from the host will be sent out over I2S channels 0..7
- What would be the difference with: define SPDIF_RX_INDEX (0)?

None. This sets which index on the INPUT path SPDIF_RX is overlaid. For example you could have:

NUM_USB_CHAN_IN = 4
I2S_CHANS_ADC = 2
SPDIF_RX_INDEX = 2
This would yield an input path of 4 channels where the first two are the I2S inputs and the second two are SPDIF input.

Who is online

Users browsing this forum: No registered users and 6 guests