TDM Master Xcore-200 using version 7.0.0

Discussions about USB Audio on XMOS devices
xmos_user123
Member
Posts: 13
Joined: Tue Oct 01, 2024 1:43 am

TDM Master Xcore-200 using version 7.0.0

Post by xmos_user123 »

Hi All,

I'm trying to use the XMOS as a TDM Master and simply do 8 channels of TDM audio on a single pin. I see there are issues due to low level timing with xcore-200 in the newer versions of SW_USB_AUDIO [https://github.com/xmos/sw_usb_audio/issues/99] and I've been experiencing issues where the data will drop for up to 750ms at a time. I'm trying to revert to USB Audio version 7.0.0 where I had a TDM master setup working in the past, however, when I try to run

Code: Select all

xmake all
on version 7.0.0 I get the following error:

Code: Select all

Checking https://www.xmos.com for required libraries
ERROR: No compatible version found for lib_xua.
ERROR: No compatible version found for lib_xud.
For context:
I'm using this version of USB Audio: https://github.com/xmos/sw_usb_audio/tree/v7.0.0alpha0
XTC Version: 15.1.4
User avatar
Ross
Verified
XCore Legend
Posts: 1085
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

The older releases of USB Audio are using the old build system (the original xcommon), that try and grab dependencies from xmos.com, but they do not reside there at the moment (we are actually looking to revert back to supporting this old model as it assists people where GitHub access is an issue)

It seems we are no longer linking to old releases on the main USB Audio pages on xmos.com. I'll get this rectified, they are linked here: https://www.xmos.com/file/sw_usb_audio-sw/

You can also grab the whole source code bundle from the release "assets" on the GitHub release page, in this instance, https://github.com/xmos/sw_usb_audio/re ... .0.0alpha0

Newer releases of USB audio come equipped with the "new" build system: xcommon-cmake. This will grab dependencies automatically for you (currently from GitHub, but we're looking to extend to grabbing from xmos.com when that's fully populated again - again this helps people without good GitHub access, users in China for example)

TBH it would probably be best to try and support you on the latest code-base. It's likely not a hard issue to solve on the bench, remotely does add another element of course!

In the code-base we're prioritised making xcore.ai designs more robust, removing the lines referenced in the issue would help xcore-200 performance.

However, 750ms would be a long time for a low-level issue as described, I would expect a bit shift or similar.

Is the code otherwise un modified?
Technical Director @ XMOS. Opinions expressed are my own
xmos_user123
Member
Posts: 13
Joined: Tue Oct 01, 2024 1:43 am

Post by xmos_user123 »

Hi Ross,

Thanks for those references! I was able to build and run the older version of 8 channel. I was also able to root cause the issue to a Mac settings. For some reason the audio tends has the cutting out behaviour with my default Mac settings, but if I go to Logic Pro -> Settings -> Audio and select the input/output devices there instead, the audio no longer cuts out. I wonder if it has to do with explicit setting the IO Buffer size? Either way I can build 8, 16, and 32 channel TDM8 configs with no issues.
Screenshot 2024-10-01 at 11.55.45 AM.png
I did have another request (I can make a separate thread for this if you prefer): Is there a way to do an internal fanout so we have 8 channels out of the Mac, but duplicates the same 8 channels on 4 different pins to have 32 channels out?
You do not have the required permissions to view the files attached to this post.
User avatar
Ross
Verified
XCore Legend
Posts: 1085
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Pleased to hear you're up and running!

So, you'll want to set NUM_USB_CHAN_OUT to 8, I2S_CHANS_DAC to 32 and XUA_PCM_FORMAT to XUA_PCM_FORMAT_TDM, but I suspect you already have this sorted.

Then you'll want to over-ride the weak symbol

Code: Select all

UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[])
by putting a custom implementation somewhere in your codebase (default implementation is empty)

I'm not sure of the exact channel mappings you had in mind, but I show an example below, Excuse magic numbers..

Code: Select all

void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[])
{
	/*
	[0] -> [0]
	[1] -> [1]
	...
	[0] -> [24]
	[1] -> [25]
	...
	*/
	for(int i = 24; i > 7; i-=8)
    		for(int j = 7; j >= 0; j--)
    		{
        		sampsFromUsbToAudio[j+i] = sampsFromUsbToAudio[j];
    		}

}
You might want to unroll this for performance. Also

Code: Select all

#pragma unsafe arrays
might be your friend (one you've got it working and deffo not got any out of bounds accesses!)
Technical Director @ XMOS. Opinions expressed are my own
xmos_user123
Member
Posts: 13
Joined: Tue Oct 01, 2024 1:43 am

Post by xmos_user123 »

Thanks this was able to fanout the 8 channels among 4 different pins. Is there a way to fan out to 8 different pins, so send the same 8 channels to 8 different XMOS Dout pins?
User avatar
Ross
Verified
XCore Legend
Posts: 1085
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

replace the "24" with "56".

It's just copying values to appropriate places in the array - the function will be called with that array having it's bottom 8 entries populated with sample values from the host.

You'll need to mod the channel count defines of course - (and hope you've got enough pins/MIPS!)

Im interested to know why you need the same data output on multiple pins? Can you not just drive multiple DACs with the same data-line?
Technical Director @ XMOS. Opinions expressed are my own
xmos_user123
Member
Posts: 13
Joined: Tue Oct 01, 2024 1:43 am

Post by xmos_user123 »

Is there any risk with using port 1H as ADC0? I'm trying to input 8 channels of TDM to USB through this pin but I don't see any data on the USB side
User avatar
Ross
Verified
XCore Legend
Posts: 1085
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

1H is used internally to communicate with the USB phy - UTMI essentially. There's a table in the data sheet and lib_xud docs, but the full list is essentially see below (note XS2 based devices use an extra one that we managed to optimise out for XS3)

Code: Select all

    #define PORT_USB_CLK         on USB_TILE: XS1_PORT_1J
    #define PORT_USB_TXD         on USB_TILE: XS1_PORT_8A
    #define PORT_USB_RXD         on USB_TILE: XS1_PORT_8B
    #define PORT_USB_TX_READYOUT on USB_TILE: XS1_PORT_1K
    #define PORT_USB_TX_READYIN  on USB_TILE: XS1_PORT_1H
    #define PORT_USB_RX_READY    on USB_TILE: XS1_PORT_1I
    #define PORT_USB_FLAG0       on USB_TILE: XS1_PORT_1E
    #define PORT_USB_FLAG1       on USB_TILE: XS1_PORT_1F
    #ifdef __XS2A__
        /* XS2A has an additional flag port */
        #define PORT_USB_FLAG2       on USB_TILE: XS1_PORT_1G
    #endif
(from xud.h)
Technical Director @ XMOS. Opinions expressed are my own
xmos_user123
Member
Posts: 13
Joined: Tue Oct 01, 2024 1:43 am

Post by xmos_user123 »

If 4 of the 8 pins that we're trying to output to are on tile 1 and the other 4 are on tile 0, what has to be modified in the code to allow us to enable all 8 DACs?
User avatar
Ross
Verified
XCore Legend
Posts: 1085
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

This will be more involved, you'll need to instantiate lib_i2s on the other tile - running as i2s slave.

You'll also need to wire up the clocks to this tile (LR and Bit)

These is an example app showing this done here:

https://github.com/xmos/sw_usb_audio/tr ... 6_extrai2s
Technical Director @ XMOS. Opinions expressed are my own