cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32f103c8t6 USB Audio problem

Vitaly S
Associate II
Posted on March 21, 2017 at 03:39

Hello

I try to create an USB Audio speaker with Stm32f103c8t6. I generate project in CubeMX 4.20 for Keil v5 and i set 44100 for sound sample rate. Project compiled fine. USB device normal detected in Windows 8. Mute button in windows works normal and call function 'AUDIO_MuteCtl_FS' in file 'usbd_audio_if.c'. But when I try to play test sound in Windows everything breaks down. Stm32f103c8t6 freeze, mute button no more works, debugger in Keil disconnect from Stm32f103c8t6.

What could be the problem?

#stm32 #usb-audio #usb #stm32f103c8t6
5 REPLIES 5
Posted on March 22, 2017 at 10:33

At that moment, the function for hardware (CODEC) initialization is called, and then the data start to arrive which you should be shoveling into the CODEC. It's upon you to write those functions. Look at the examples which come with Cube for the EVAL boards.

I don't use Cube but got one of those examples working on my board. One thing to notice is that the example ruthlessly uses malloc() to get space for the data, so your program should be prepared to accept that (have enough space in heap etc.).

JW

Imen.D
ST Employee
Posted on March 22, 2017 at 10:53

Hello,

I recommended you to have a look to the

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-libraries-expansions/stsw-stm32license=14901755566html

, the USB-FS-Device Audio Speaker demo gives examples of how to use the STM32F10xxx USB-FS-Device peripheral.

More details about this Demo implementation is given in the attached User manual 'UM0424 STM32F10xxx USB development kit', in section 'USB audio speaker demo'.

Imen

________________

Attachments :

STM-STM32-STM32F103C8-Learning Centre MCU-User Manuals-STMicroelectronics.Manuals_1.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hylg&d=%2Fa%2F0X0000000bCF%2FnX6HZ1M30SPw9CfoS9.f5U2jOxA4bch25D21zf75DyI&asPdf=false
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on March 22, 2017 at 20:31

I set heap size to 0x2000,

set AUDIO_OUT_PACKET_NUM=20

and set correct size of static buffer in malloc function static uint8_t mem[4096];

Now I was able to receive a sound data from PC, but only once. 

Stm32f103c8t6 does not freeze now, but it need to reconnect to PC USB after each first sound data packet.

Posted on March 22, 2017 at 20:37

Thanks for the example.

In the example used 8bit 22KHz sound. Is it maximum for 

STM32F10xxx? I need 16bit 44100 two-channel sound,  can 

STM32F10xxx work in this mod?

Imen.D
ST Employee
Posted on March 23, 2017 at 11:25

Hi,

You should refer to the reference manual and datasheet related to your device for more clarification about your product characteristics.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen