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
Using 4-bit port for TDM on XU208
-
- Experienced Member
- Posts: 99
- Joined: Sat Aug 31, 2013 11:23 pm
-
- XCore Expert
- Posts: 580
- Joined: Thu Nov 26, 2015 11:47 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
-
- Experienced Member
- Posts: 99
- Joined: Sat Aug 31, 2013 11:23 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)?
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)?
-
- XCore Expert
- Posts: 580
- Joined: Thu Nov 26, 2015 11:47 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.
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.
-
- Respected Member
- Posts: 283
- Joined: Fri Mar 19, 2010 4:49 am
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.
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.
-
- XCore Expert
- Posts: 580
- Joined: Thu Nov 26, 2015 11:47 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.