How to sync the sample rate of USB UAC example with DAC sample rate?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to sync the sample rate of USB UAC example with DAC sample rate?

2,487 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cgha on Thu Dec 20 19:52:06 MST 2012
I want to use 48K HZ sample rate at DAC side using I2S communicate to LPC1768, but after enumerated by host pc and play audio , the PCM data buffer on lpc1768 will get hungry or overflow because the clock is different on two side, So how to implement to get them sync to the same clock? In the config descriptor, I've changed the ISO endpoint to Asynchronous.
Thanks!

ChrisChen
Labels (1)
0 Kudos
3 Replies

1,660 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cgha on Fri Dec 21 23:10:06 MST 2012
If my mcu does not support SOF interrupt,how to calculate the feedback value?
I want to implement like this,One ring buffer, if it has reach 2/3 length of the ring buffer, then feedback 47<<14, if reach 1/3 length of the ringbuffer, then return feedback 49<<14, ignore the first time. Else return 48<<14.

ChrisChen
0 Kudos

1,660 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cgha on Fri Dec 21 06:58:57 MST 2012
Thanks,your explaination is the point what I need, I will learn the uac spec first, Thanks!
Do I need a special host driver if I want to talk to MAC or IOS? Thanks again!

ChrisChen
0 Kudos

1,660 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DF9DQ on Fri Dec 21 03:59:51 MST 2012
Hi Chris,

Asynchronous mode is the correct mode for the LPC1768, since you have no way of synchronizing the I2S clock to the USB (SOF) clock. Only the host can prevent a buffer overflow or underflow by adjusting the rate at which it sends samples. It does this by sending one sample less or more in certain frames.

For the host to know whether your sample buffer is going to over/underflow, you must provide feedback to the host. There are basically two options: explicit feedback and implicit feedback.

Explicit feedback must go through an extra isochronous endpoint. You monitor the speed of incoming (USB) and outgoing data (I2S). If you see that I2S drains your buffer faster than it gets refilled by USB, you report, for instance, "48.05" to the feedback pipe. The host will then increase its average sample rate by a factor of (48.05/48).

Implicit feedback can be used if your device also implements an isochronous data source (device->host). If both are derived from the same clock (the source marked as asynchronous as well), the host uses the amount of samples coming through the source pipe as a measure to adjust the rate at which it sends to the sink pipe.

You can find a description of the procedure and feedback channel data format in the USB spec (USB Data Flow Model, Synchronization Types), chapter 5.12.4 in my very old 2.0 copy.

I'm not an expert in this field though, but I hope this gives you a good start.

Regards,
Rolf
0 Kudos