2022-07-12 03:01 PM
2022-07-12 03:11 PM
Some details: I tried to write a simple usb audio speaker with the STM32F103 Bluepill using STM32CubeMX (again). No success. Then I switched to an F411 Blackpill, its working in a minute.
I Googled a lot, there is not a single succesful effort on the net using the HAL library for USB audio speaker (however SPL audio middleware is working). No ST usb audio sample code for this family.
So either the CubeMX generated code is broken, or no one was able to figure out how to use it.
Please, ST, take a look into it...
2022-07-13 08:28 AM
Well, you have asked essentially the same question before.
STM32F103 Bluepill?
I wouldn't be surprised if this is also due to the STM32F103 counterfeits that have been used on the Bluepills for a long time, i.e. they are usually not original parts from STMicroelectronics.
Regards
/Peter
2022-07-13 11:11 AM
Sure, I hoped that the new HAL version is better.
It's definitely an original ST uC from the good old times. I tried it with a Nucleo as well. I am pretty sure it's broken code.
2022-07-13 11:54 AM
The HAL for the STM32F1 has not changed for a year, the STM32_USB_Device_Library has been unchanged for much longer and is essentially identical to that of the STM32F4.
What do you mean by "new HAL version"?
Regards
/Peter
2022-07-13 12:49 PM
The version number of the STM32CubeMX increased. I hoped, that ST corrected the broken code.
The HAL for the STM32F1 has not changed for a year
Considering it's not working, and it's a known "feature", it's not good news.
essentially identical to that of the STM32F4
Essentially... :-)
The F411 code is working, but the f103 and f303 is not working. It's not just me, there is not a single working project on the net. The SPL library is working.
2022-07-13 11:37 PM
The version number of STM32CubeMX has nothing to do directly with the version number of the libraries. If it is about special functions of the HAL or LL, you should therefore look there first.
If something does not work as you expect, it would also be helpful to know what exactly you tried, so that it can be understood and tested.
Regards
/Peter
2022-07-14 05:41 AM
If something does not work as you expect, it would also be helpful to know what exactly you tried, so that it can be understood and tested.
Sure, thank you for help.
I tried to make a simple isochronous usb sound transfer from the PC to the STM32F103C8T6 (original ST uC, not a clone).
What I did:
Using STM32CubeMX (latest) set the clock system (8MHz crystal HS osc, 72MHz clock, 48MHz for the USB).
Enable serial wire debug.
Connectivity/ enable the USB, default parameter settings (full speed, Rx0 interrupt enabled).
Middleware/ enable USB_Device, select Audio Device Class, set USB_Audio_Freq to 48000.
Project manager/ minimum heap size to 0x2400, stack to 0x1000 (because the generated code uses malloc)
Generate code for Keil 5. Compile, no errors. Upload to device.
Test it:
Connect the to PC, Win11.
It enumerates, win11 recognises it as audio device.
First test, as simple as possible:
I select first my PC's built-in soundcard, and start a video in order to start audio stream. I hear the music.
Then I select the STM32 audio device on the PC. My expectation is silence, as the uC receives the stream, but there is no any processing of the stream.
But no, a short (shorter the 1 sec) pause in the sound, and the PC's sound card plays the music again.
It means, that my uC device failed to receive the audio stream, Win11 dropped it and switched back to the built-in soundcard.
I did this test using exactly the same settings etc. with an STM32F411 board, it is working as expected. Select the board: silence. Select the built-in soundcard, music. Repeat, allways working.
Then I wrote a simple test code for the F411 to handle the stream using the callback, and a PWM channel, it is working, I can hear the music from the uC, so it is definitely working well. (It's just a test, my project is not a usb speaker, but a HAM radio project that needs audio processing in the uC.)
Another test using the STM32F103 code and a debugger:
Hope, it's detailed enough for reproducing the problem.
While I have no deep knowlidge in the HAL library (I just like to use it, not debugging it), I am not absolute beginner. I was able to use it with the F411, and wrote a working usb audio code for the F103 too using the SPL. Tried tinyusb library as well with success.
regards,
Jozsef
2022-07-19 04:57 PM
With rare exceptions, almost everything in HAL/Cube code is broken and bloated. You cannot expect a reliable device, which is built on broken bloatware. And you cannot expect a decent code from incompetent developers...
Stick to TinyUSB - it is decent, rapidly evolving and designed by competent developers.
2022-07-22 01:32 AM
Tinyusb has no isochronous transfer support for the stm32F1xx and stm32F3xx family. I learned it the hard way, first tried it, and made an unsuccesful test. Then debugged it, and found the reason. Then Googled the forums and got the claim it's not supported...
So far the only working example is the UM0424 "STM32 USB audio speaker demo".
For the stm32F411 either the CubeMX generated code or Tinyusb is working too.