Using 4-bit port for TDM on XU208

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
genap
Experienced Member
Posts: 94
Joined: Sat Aug 31, 2013 11:23 pm

Using 4-bit port for TDM on XU208

Postby genap » Sun Feb 28, 2021 5:17 pm

Hi,

I have a usb audio design which requires 4 OUT and 16 IN audio channels @48KHz.
Not to mess with multiple audio clocks I am going to use TDM4_OUT and 4xTDM4_IN.
To implement this by a standard approach I need 5 1-bit ports.
Unfortunately I have only 4 1-bit ports available. But I have ports P4C and P4D fully available.
So if it's possible to use 4_bit port for audio without significant code changes,
I can use 4 TDM4_INs on 1-bit ports, TDM4_OUT on a 4-bit port (or TDM4_OUT on a 1-bit and 4 TDM4_INs on a 4-bit, but it's probably more complicated) .

Please advise on a possible solution and approach
User avatar
akp
XCore Expert
Posts: 514
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Mon Mar 01, 2021 2:45 pm

Yes, it's possible. Refer to this application note for I2S, you just need to extend it to four channels per pin from two. https://www.xmos.ai/download/AN10129:-U ... .1rc1).pdf
genap
Experienced Member
Posts: 94
Joined: Sat Aug 31, 2013 11:23 pm

Postby genap » Mon Mar 01, 2021 4:31 pm

Thank you akr,
as far as I understand, the above applies to using multiple pins of a 4-bit port.
What if I want to use just one pin of a 4-bit port for TDM4 (other pins on this port are not used)?
User avatar
akp
XCore Expert
Posts: 514
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Mon Mar 01, 2021 4:54 pm

I think the same basically applies, you just need to stuff zeros for the unused channels if you're using TDM out (because the pins will definitely be outputs) or drop the unused channels on TDM in.

You can probably optimize the code a bit knowing you're only using 1 pin of the TDM out for instance, which might get you more speed. But I don't think 48 kHz will be a problem. I would say your idea of partitioning the problem makes most sense if you're trying to hit a higher frequency. The optimum from a pin resource usage perspective is to do the 4 x TDM4 in on the 4 bit port and use a 1 bit port for the TDM 4 out of course.
bearcat
Respected Member
Posts: 279
Joined: Fri Mar 19, 2010 4:49 am

Postby bearcat » Mon Mar 01, 2021 6:47 pm

I would think you would implement the 4X TDM4_IN on your 4 one bit ports. This is probably fairly easy and low overhead as there is no need to multiplex the bits. But data rate is pretty high with TDM.

Then the TDM4_OUT on the 4 bit port (lowest bit on the port if bit bang). I believe there are 2 options. You can bit bang the data is the easiest, but quite a high data rate. The second is to multiplex with the zip and unzip instructions. This allows to select a 32 bit width and use the port buffering, so fewer writes, but more overhead in the code.

I have implemented 4 I2S inputs using a 4 bit port with data rates up to 96K in my case, using the zip instruction, with 1 thread (that also supported several other 1 bit I2S channels in the same thread). With TDM4 you are 4x the data rates. That would need testing and optimization to see if possible with 1 thread.

Flipping the in and out would free up 3 one pin ports. But would need to multiplex more data. Again testing needed to see if feasible.
Last edited by bearcat on Mon Mar 01, 2021 6:56 pm, edited 1 time in total.
User avatar
akp
XCore Expert
Posts: 514
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Mon Mar 01, 2021 6:50 pm

I think TDM4 is just 2x the data rate as I2S. So TDM4 at 48kHz will be the same as I2S as 96kHz. TDM4 is the same as TDM128.

Who is online

Users browsing this forum: No registered users and 0 guests