STM32F4 UAC2 High Speed USB 16-bit Mono Microphone #2946
Unanswered
mijnendatum
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all!
For the past years I have worked with the STM32 family of microcontrollers and used their built-in USB CDC functionality with the ST USB drivers (unfortunately). Last week, I had the idea of using a STM32F429 with an external PHY, which has worked in the past reliably to create a higher speed CDC device, to build a USB microphone with a sample rate of 384kHz.
After some looking around on the internet, it appeared that this would need the UAC2 device class since this supports higher sample rates. It also appeared that ST does not (yet) support this device class which brought me here to TinyUSB.
After some trial and error, I got the UAC2 headset example to work with the sample rate of 384kHz with the output device loopback. At least, that seemed to work with a recording in audacity.
After some more experimenting, I reworked the example to ditch the output device and solely enumerate as a 16-bit mono microphone with the aforementioned sample rate. I figured to get the data input working, so I went to work with getting the on-board single channel 12-bit ADC up and running with a timer triggering the ADC sampling at 384kHz and a double-DMA buffer to acquire the data.
Upon a transfer complete of the DMA controller, either the first or second half of the memory buffer would be pushed to the USB FIFO by using
tud_audio_write((uint8_t *)DMA_ADC_buffer[0], (uint16_t) (DMA_ADC_BUFFER_SIZE));
This means, my while loop only contains the tud_task() since all the audio_task() is done in the DMA interrupt routine.
When I flash my device with this firmware, hook up a 1kHz sine wave to the ADC pin and try to measure this in Audacity, the only thing i get is static and I don't know what the cause could be.
I tried manually setting the EP buffer size to 196 (which is the max buffer size AFAIK), but that did not help.
I am open to suggestions since I am starting to get out of ideas.
Beta Was this translation helpful? Give feedback.
All reactions