Hi all,
I am implementing a stereo, 16bit-res microphone application. The application should send the recorded data over USB to PC.
I succeeded to make the microphone work well at 48kHz and now I am stuck at isochronous transfer at 44.1kHz.
The isochronous transfer type is Synchronous. And the In endpoint max packet size is 192bytes.
I use the 'usblyzer' to grab the packets that I found 3 different results:
(1) When I send 176 bytes data to PC every millisecond. PC can received 1760bytes/10ms. (2) When I send 180 bytes data to PC every millisecond. PC can received a random amount of data between 500 to 800. (3) When I send 9 x 176 bytes and one 180 bytes every 10 millisecond. PC can received 1412bytes/10ms or 1760bytes/10ms(4x1412 and 1x1760 as a period).
So I guess I made a mistake at how to transfer the streaming data at 44.1kHz over usb to pc.
Can anybody tell me how to transfer streaming data at 44.1kHz over usb to PC?
> (3) When I send 9 x 176 bytes and one 180 bytes every 10 millisecond. This could be the right way, if you would write it as "10 frames", instead of "10 milliseconds".
1 frame is not exactly 1 ms. It’s 1ms +/- 500ns, determined by the host. In Synchronous method, your local sampling clock has to synchronize to SOF timing.
I recommend you [b]A[/b]synchronous instead of Synchronous, for easy microphone implementation.
In Asynchronous method, your local sampling clock is the master clock. The number of samples in a packet is determined by the number of samples in the last SOF interval. And then, you don’t need to worry about either 44.1 or 48 kHz.
Tsuneo
Thanks for your reply.
I had solved this problem now. It is because of the Max packets size of IN_EP was set to 176 bytes.
But I am actually working at the SYNC problem(FIFO overrun & underrun). I am still learning on that three methods(sync, async, adaptive) and I think it is hard for me.
> I am still learning on that three methods(sync, async, adaptive) and I think it is hard for me.
The synchronization concept is not so difficult, though the implementation is another story. As the USB audio consists a real-time system, host, bus and device should be synchronized each other. Sync, async and adaptive mean the place where the master clock exists.
Synchronous - bus (ie. SOF timing) is the master clock. Host and device synchronize to SOF
Asynchronous - Device has the master clock. Bus transfer and host synchronize to device
Adaptive - Host has the master clock. Bus transfer and device synchronize to host.
Device declares Synchronization method at bmAttributes field (bit3..2) of the isoc endpoint descriptor. 00 = No Synchronization 01 = Asynchronous 10 = Adaptive 11 = Synchronous
A) Synchronous microphone Here is a typical implementation of Synchronous microphone.
1) Generate local sampling clock, synchronized to SOF A timer, driven by SysClock, counts SOF interval at every SOF timing (triggered by hardware SOF output or SOF interrupt). The count is divided by sample numbers at frames, and divided values are fed to another timer to generate sampling clock.
For example, 10 frames of SOF intervals counts up to 500,021 counts over 50 MHz SysClock. 500021 counts / (44.1 samples/frame * 10 frames) = 1133 base counts / sample .. 368 remainder
The second interval timer (sampling clock generator), also driven by SysClock, is set to 1134 counts (base+1) for the first 368 intervals, and 1133 base counts for the rest (441 - 368) intervals.
This operation is repeated at every 10 frames. In this way, you have sampling clock, synchronized to SOF.
2) Sample data on a buffer Driven by above sampling clock, an ADC fills sample data to a buffer.
3) Transfer to host At every SOF timing, the increments of the samples on the buffer is captured. The firmware sends samples of the increments from the buffer to the isoc endpoint.
B) Async microphone The implementation of Async microphone is almost same, except, 1') The device runs its own sampling clock.
The frequency of this sampling clock doesn't need to be exactly 44.1kHz, because the bus transfer and host synchronize even to slightly-deviated sampling clock.
Thanks for your reply again. It is very helpful to me. Thankyou very much!
Jason