I’ve recently been doing some work on the STM32F1 ARM chip. In particular I modified one of the ST USB Audio Speaker projects to suit a particular need.
Being an ‘audiophile’ I wanted to see if I could get 24bit, 96kHz, stereo out through the USB interface. Many people say that you can’t actually get higher than 192kHz out of USB 1.1 or Full Speed USB. You can then DMA the data to the 12bit DACs onboard and have yourself a little wee music player / recorder.
Not including USB3.0, there are three USB speed levels, low speed, full speed and high speed. (1.5Mbits, 12Mbits, 480Mbits)
The STM32F103 device actually supports USB full speed. Better devices support high speed, but an external PHY is required (they’re so sneaky about that!!!).
USB Audio uses the USB Isochronous transfer mode.
- Low Speed – Isochronous is not allowed
- Full Speed – Isochronous, upto 1023 bytes per 1ms frame
- High Speed – upto 3x 1024 bytes per 125us frame*
*High speed frames are actually called ‘microframes’
I’ll focus on the Full Speed bandwidth for now as the STM32F103 only supports Full Speed.
Doing the Maths,
- Full Speed bandwidth (bytes / second ) = 1023 * 1000 = 1023000 bytes per second.
So how does this 24bit, 96kHz, stereo limitation come about?
- 24 bits = 3 bytes * 96000 samples per second * 2 for stereo channels = 576000 bytes per second
- 24 bits = 3 bytes * 192000 samples per second * 2 for stereo channels = 1152000 bytes per second <— too much data for Full Speed noooo!!!!!!!
Furthermore, I’ve discovered that the STM32F103 only has a 512 byte USB buffer! Ouch!! Thus our isochronous frames can only handle 512 bytes, not the full 1023 bytes!! Things just are getting worse and worse!!
This means that we can’t even do Stereo, 24bit @ 96kHz as it requires 576 bytes per frame. We could do Stereo 16bit @ 96kHz (384 bytes per frame).
And so the journey ends. The STM32F103 is incapable of 24/96kHz, what a let down :(Does anyone have any ideas to get around this, or have come across a similar issue? Let me know, I’d love to hear what you’ve done!
I know there is a double buffering feature that gets used on this device, I thought perhaps there’s a way to use this to extract more data quicker, but alas, no, it applies only to separate frames, and besides, the entire USB buffer is limited to a stingy 512 bytes!
Bulk USB Audio Transfers anyone??