How to make the diyinhk multichannel i2s interface receive slave lrck? Topic is solved

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
T-5
Member
Posts: 11
Joined: Wed Jun 26, 2019 3:59 pm

How to make the diyinhk multichannel i2s interface receive slave lrck?

Postby T-5 » Wed Jun 26, 2019 4:16 pm

Hi all!

we are working on a 12 channel dac project and want to use two DIYINHK 6 channel/384kHz USB to I2S audio interfaces.
https://www.diyinhk.com/shop/audio-kits ... f-pcb.html

To make these two synchronous we already removed the output clocking oscillators from one board and linked the clocks of the two boards together. Works a treat.

BUT: The LRCKs are out of sync as can be seen here: https://t-5.eu/owncloud/index.php/s/D1oL9C7uYBXcEVe
The amount of phase shift depends on the time the devices are plugged in...

No we want to modify the firmware on one of the boards to accept the lrck of the other boards and slave to it.

What are the prerequisites to do this? What kind of programmer do we need, what is a good starting point for the firmware?

Thanks in advance!
View Solution
User avatar
akp
Respected Member
Posts: 314
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Wed Jul 03, 2019 1:07 pm

Just compile the code for the 2nd board with I2S slave IP rather than master, and connect the LRCLKs together, and you'll be fine. I don't know the board myself but if you have the source it's pretty easy.
T-5
Member
Posts: 11
Joined: Wed Jun 26, 2019 3:59 pm

Postby T-5 » Sun Jul 14, 2019 7:19 pm

OK, we got our XTAG3 programmer now. I managed to read the flash contents and make a backup first.

After some tinkering around I managed to build an example and flash it to the chip. Then it was dead. :) (no USB device detected by OS)

I flashed back the backup and revived the board. Good news so far.

As we DON'T have the source code from DIYINHK (they claim licencing issues are the reason why they cannot give us the source) now the main question is, which example project to use in the first place. The chip used on the DIYINHK board is a XUF216-512-TQ128-I20.

PS: I found the define (CODEC_MASTER) in the module_usb_audio so i know what define to change in the example app already.
User avatar
akp
Respected Member
Posts: 314
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Mon Jul 15, 2019 1:12 pm

You will probably need the schematic. I don't know if you have it. But if you do then you can probably modify the app_usb_aud_xk_216_mc because it basically uses the same processor and flash. But I don't know anything about the pinmux used on your board (i.e. which pins on the processor correspond to the I2S signals), so that's why you'll need the schematic to modify the project if necessary for the pinmux. There are existing configurations for both master and slave I2S modes so perhaps you can generate new configurations or modify the existing ones for your hardware. Good luck!
T-5
Member
Posts: 11
Joined: Wed Jun 26, 2019 3:59 pm

Postby T-5 » Mon Jul 15, 2019 2:58 pm

I just discovered the different build targets in the Makefile. Is this what you refer to als configurations? If so, how do I enable different configurations to build in xTIMEcomposer?
User avatar
akp
Respected Member
Posts: 314
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Mon Jul 15, 2019 3:01 pm

Right. If you right click on the project you should be able to go to Build Configurations > Set Active
You can also manage the configurations from a similar place. In case on the build configurations you use isn't automatically identified by xTIMEcomposer
T-5
Member
Posts: 11
Joined: Wed Jun 26, 2019 3:59 pm

Postby T-5 » Mon Jul 15, 2019 6:32 pm

I think we're getting there :)

For testing the if the board works at all with the example project I used:
app_usb_aud_xk_216_mc 2i10o10xxxxxx

The device now is recognized:
[76469.914851] usb 1-4: new high-speed USB device number 125 using xhci_hcd
[76470.063427] usb 1-4: New USB device found, idVendor=20b1, idProduct=0008, bcdDevice= 6.f2
[76470.063431] usb 1-4: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[76470.063433] usb 1-4: Product: xCORE USB Audio 2.0
[76470.063435] usb 1-4: Manufacturer: XMOS

But after 5 seconds i get:
[76475.179645] usb 1-4: parse_audio_format_rates_v2v3(): unable to find clock source (clock -71)
[76475.180439] usb 1-4: parse_audio_format_rates_v2v3(): unable to find clock source (clock -71)
[76475.181987] usb 1-4: cannot get ctl value: req = 0x83, wValue = 0x201, wIndex = 0xa00, type = 4
[76475.181995] usb 1-4: 10:0: cannot get min/max values for control 2 (id 10)
[76475.182201] usb 1-4: cannot get ctl value: req = 0x83, wValue = 0x200, wIndex = 0xa00, type = 4
[76475.182208] usb 1-4: 10:0: cannot get min/max values for control 2 (id 10)
[76475.182448] usb 1-4: cannot get ctl value: req = 0x83, wValue = 0x201, wIndex = 0xb00, type = 4
[76475.182455] usb 1-4: 11:0: cannot get min/max values for control 2 (id 11)
[76475.182527] usb 1-4: cannot get ctl value: req = 0x83, wValue = 0x200, wIndex = 0xb00, type = 4
[76475.182535] usb 1-4: 11:0: cannot get min/max values for control 2 (id 11)
[76475.184419] usbhid 1-4:1.4: can't add hid device: -71
[76475.184454] usbhid: probe of 1-4:1.4 failed with error -71

The "10:0: cannot get min/max values for control 2 (id 10)" lines are then repeated lots more times.

Any idea what is going wrong here?

Btw i also tried some other sensible build configurations like 2i10o10xssxxx etc... All with the same errors,
so maybe the "unable to find clock source (clock -71)" is hinting at a different clock input pint that is used
on this board? Just a thought of mine.

Btw. we don't have the schematic available but reverse engineering the pins that are used should be fairly easy.
Where are the pin assignments done in the source, i.e. which source file?
Last edited by T-5 on Mon Jul 15, 2019 7:14 pm, edited 1 time in total.
User avatar
akp
Respected Member
Posts: 314
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Mon Jul 15, 2019 6:43 pm

Definitely getting somewhere fast now, I'd say. You'll need to change the audiohw.xc. If you have USE_FRACTIONAL_N defined, then the code assumes you have a PLL on the board, specifically the CS2100. So if you have a fixed oscillator you'll need to change the code so it doesn't try to init the PLL (i.e. undef USE_FRACTIONAL_N).

And you'll probably need to define what the oscillator frequency is in the customdefines.h. If you refer to the other projects you can see they actually have 2 oscillators muxed (0 - 22.5792MHz, 1 - 24.576MHz). So you'll have to figure out what you have (this is probably what you have but I don't know). Also the audiohw.xc is going to try to configure the ADC and DAC, and that won't work if you don't have those chips.

For the actual pinmux I think you may have to do that in the .xn file, you might want to make your own and call it out in the Makefile, based on the xk-audio-216-mc.xn
T-5
Member
Posts: 11
Joined: Wed Jun 26, 2019 3:59 pm

Postby T-5 » Tue Jul 16, 2019 9:24 pm

Yay! I undef'd USE_FRACTIONAL_N and emptied out the function bodies of PllInit(), PllMult(), AudioHwInit() and AudioHwConfig() in audiohw.xc .
The device now comes up on USB and throws NO errors in dmesg. Nice :)

I can't test wether the right I2S pins are configured right now as my oscilloscope is at a friend's house. Will do that probably later that week.

Right now I have two more questions:

1. As we need 10 Channels of I2S, i.e. 5 I2S lines, can the XU216 do that at 192khz? The stock firmware offers 8 channels I2S and 2 channels SPDIF. If i could reuse the SPDIF pin (or any other pin) for a fifth I2S line we would be golden and could ditch the whole slaving method alltogether and just use one board instead of the two. Way cleaner approach IMHO. From what I see in the build configurations there's a "2i10o10xxxxxx" which seems to just do that - output to 5 I2S lines?! We even don't need any inputs so those could be disabled if that helps...

2. The DIYINHK board uses a GPIO pin to switch the VCC inputs of two oscillators, depending on the sampling rate family. I want to preserve this functionality. It's obvious that I will have to configure the same pin that's used now as GPIO and set it to low/high depending on the sampling rate family. Can I do that in AudioHwConfig()? One of its parameters seems to be the sampling rate...

Sorry for all the noob stuff coming your way and thanks a lot for all the useful help so far!!!
User avatar
akp
Respected Member
Posts: 314
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Thu Jul 18, 2019 9:22 pm

Can you use TDM instead of I2S? The board can do 8 ch of TDM per existing I2S line so that would increase your channel count from 8 up to 32 with 4 TDM lanes.

Who is online

Users browsing this forum: No registered users and 2 guests