USB Audio and DSD256 problem Topic is solved

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

USB Audio and DSD256 problem

Post by mmar »

Hello all Xcore users,
i make own DSD code for audio design and now have trouble with DSD256 DOP stage.

in reference usb audio design is all code i2s based on this defined ports:

/* Audio I/O */
on stdcore[0] : buffered out port:32 p_i2s_dac[1] = {XS1_PORT_1D};
on stdcore[0] : buffered out port:32 p_lrclk = XS1_PORT_1C;
on stdcore[0] : buffered out port:32 p_bclk = XS1_PORT_1A;

For us design we need in runtime change this size buffer from 32 to 16 bits and back. (in ConfigAudioPorts(divide);)
I try found howto do this , or how write to buffer 16 + 16 bits , but need help.

This statement write to buffer alltime 32 bit , too when unsigned short i use for channel write.

unsigned short c[3];
...
p_i2s_dac[0] <: c[0];

This alltime shifts 16 bit + 16 zeroes.

I found function
partout(p_i2s_dac[0],16,c[0]) that seems work better as previous 32bit write, but no ok.

On DSD256 i need 1bit with 11...Mhz clock and data over DOP is 16 bit in one cycle channel.

Then in first cycle i write first 16 bit part of 32 bit buffer, but in second i need write next 16 bits. I dont understand how this exactly work .

Can anybody write example how send this with proper timing when clock of port is 11...MHz
in two cycles of audio get/put ? Maybe for this clock is need timed partout or?

Regards Marian.


View Solution
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

DSD256 eh? Thats some fast DSD! Which DAC supports that speed please?

Regarding the "transfer width" of the port I would use a small line of inline ASM:

Code: Select all

asm volatile("settw res[%0], %1"::"r"(p),"r"(transferwidth));
Does that help?

By the way, I've been working on my own DSD implementation and have used a transfer width of 32 throughout. I know the DoP spec lists 16bit data in the 24/32bit PCM sample - is this why you want to use 16bit outputs to the ports?

I construct the 32bit word to the port from two DSD "Samples", then output these 32bits to the port.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

Thanks for asm i try this on monday. This maybe is speed issue.
DSD256 is 11.2896MHz , this is equal to MCLk , and too port clock for dsd data.
But i mean XS core have power to do this stream.

All PCM179x have this top and support DSD256.

I make dsd based on deliver and this for divide 1 use timed out call to port.
This i mean is need for DSD256 too.
When i send first 16 bit , then for second partout is need timed call.
Can anybody write example for this?

Or explain for me how works partout on example.

M.
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

mmar wrote:
All PCM179x have this top and support DSD256.
Interesting. I was wondering about DSD128 support on the PCM1795 - I'm working with one at the moment. I was going to give it a try as I know the max clock freq for DSD is stated as 11.2896MHz but the Sampling Frequency only states 2.8224MHz.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

why my profile miss? ffor moderator.

In pdf is 2.8MHz in typical freq. Min and max is undefined.
From theory you may use any sample freq. btw 4.000MHz and playback is ok
if source is sampled identic.

I repeat my q how partout work, btw. if i use four partout 16 bits into 64 bit buffered single bit port.

partout1
...some code
partout2
...some code
partout3
...
...
how data go out from pin.
I mean in my code second partout is to late and some data on out port timeuots.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

I read more docs and buff widths supported is only 32,8,4,1 .
Is this true or not. Can i use with asm writed by ross 16?
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

you can use partouts in XC, no problem - but I suspect the code is not running fast enough.

I really would encourage you to doing 32bit outputs to these ports - create one 32bit output from two 16bit chunks. Something like this:

Code: Select all

        if(!everyOther)
        {
            dsdSample_l = ((samplesOut[0] & 0xffff00) << 8);
            dsdSample_r = ((samplesOut[1] & 0xffff00) << 8);
 
            everyOther = 1;
  
            // Output clocks..
        }
        else
        {       
            everyOther = 0;
            dsdSample_l =  dsdSample_l | ((samplesOut[0] & 0xffff00) >> 8);   
            dsdSample_r =  dsdSample_r | ((samplesOut[1] & 0xffff00) >> 8);   

            p_dsd_dac[0] <: bitrev(dsdSample_l);
            p_dsd_dac[1] <: bitrev(dsdSample_r);

            // Do clocks...

        }

mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

Thanks Ross,
but this code i use as first . Dont work. Your asm too dont work.
This seems as slow decouple code and second samples not arives intime.
Then on scope i see one 32 send ok and next 32 stay on last value from previous.

Howto i can speed up trace USB-buffer-decouple-dsp-audio?
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

I assume the code is stuck on the second out instruction?

Is this because you haven't driven the clock to drive it out?

That code does work for sure, admittedly I have only tried it using DSD64.
mmar
Experienced Member
Posts: 123
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

Ross,
i use slightly different code for 64 and 128 and all is ok.

I use for all signals same clock 11.2896MHz.
And now on 256 only diff is i need two sample for construct 32.
In 64,128 this is not need and my code work ok .

I see that handshaking between decouple dsp and audio is slow for this.
Time elapsed in code for get two samples is more as 32 ticks of bit clock.

Split this to two 16 bit partouts not help . Time to obtain next 16 is too slow.

My query is how to speed this up.