Usage of USB driver in isochronous mode (STM32)

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

Kosyak
Posts: 14
Joined: Tue Jul 22, 2014 3:22 am

Re: Usage of USB driver in isochronous mode (STM32)

Postby Kosyak » Thu Mar 24, 2016 4:35 pm

Hello again, folks!

Here is updated demo project. It's using new ChibiOS USB API now.

1- In order for this to become a more general demo, use differen endpoints for audio stream output and feedback, because while it's totally OK to use a single endpoint working bidirectionally as you do, the USBv1 peripheral in devices other than the STM32F4 family can't do bidirectional isochronous. It's an inherent limitation of the peripheral.

Done, feedback moved to EP2.

2- Use a GPIO and a scope and display your data pump execution time. You'll be surprised. chIQReadTimeout is awfully slow, in fact, in my tests on a STM32F072 @49.152Mhz (yes, slightly overclocked) it takes >1ms for each 192 byte packet (48 samples, 16 bit, 2 channels) which means it can't cope with the actual data inflow. It's a no go. You probably got away with it because you're running a much faster STMF4.

Fixed, USB driver is writing directly to I2S buffer. Now you can enjoy nice dubstep-like effects when buffer is underruning often :) (shouldn't happen if your host supports async USB audio).
Attachments
USB_AUDIO_I2S.zip
(24.02 KiB) Downloaded 428 times

yusuf.husainy
Posts: 9
Joined: Sat Jan 27, 2018 1:33 am
Has thanked: 4 times
Been thanked: 5 times

Re: Usage of USB driver in isochronous mode (STM32)

Postby yusuf.husainy » Fri Dec 04, 2020 8:24 pm

Hello,

I understand this is an older thread, I have migrated this project to Chibi20.3 on stm32f4 discovery board I have. I've connected MCLK to ITR of TIM2 using a jumper wire for samplerate feedback, as discussed in earlier posts.

On building and running, I am able to get usb audio device enumerated as ChibiOS/RT USB Audio Device. On playback, the media is audible, but has a lot of loud noise. I am not sure what type of noise, it is like a constant level, humm noise. I tried with 2 outputs, a set of earphones and my PC speakers connected to f4 discovery's audio jack.

I am not sure what to debug or look at to understand where this noise comes from and how can approach to fix it or have a workaround in firmware for it?

Any help appreciated, Thanks!

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Usage of USB driver in isochronous mode (STM32)

Postby Giovanni » Fri Dec 04, 2020 10:07 pm

Are you sure it is not some AC coupling noise?

Giovanni

yusuf.husainy
Posts: 9
Joined: Sat Jan 27, 2018 1:33 am
Has thanked: 4 times
Been thanked: 5 times

Re: Usage of USB driver in isochronous mode (STM32)

Postby yusuf.husainy » Sat Dec 05, 2020 7:28 pm

Thank you for the quick reply!

No, I don't think it is from AC coupling noise.

I ran the STM32Cube example "Audio_playback_and_record", which is basically an OTG host based device, reading from a memory thumb drive "audio_sample.wav", without any noise, very clean. This is a bare-metal application, using the Cube ecosystem firmware libraries.

So I believe, it isn't a hardware issue, need to investigate the on-board codec, CS43L22 initialization in this Chibi example code, compare it with the Cube example's initialization sequence?

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Usage of USB driver in isochronous mode (STM32)

Postby Giovanni » Sun Dec 06, 2020 9:02 am

Hi,

That is contributed code that I never had time to try, please go ahead.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 42 guests