cancel
Showing results for 
Search instead for 
Did you mean: 

USB audio overwrites received data

cym
Associate

I want to build a simple USB audio interface using STM32L432 Nucleo board. The device is detected by the computer but the sound is not played correctly. Even if nothing is played, the whole buffer is filled with 0x00 except two bytes. This is repeated for every received USB package. This leads in a 1kHz tone. Data sent through USB are all 0, so I think the USB driver must overwrite some of the receiving buffer.

Heap and stack size is already set to 0x1000 and the HSI48 is used as clock source for the USB.

Thanks for any hints.

2 REPLIES 2
TDK
Guru

When you send data, it must be valid until the transfer is complete. Are you using a global buffer or one on the stack that goes out of scope?

If you feel a post has answered your question, please click "Accept as Solution".
cym
Associate

The data are also corrupt, even if they are not sent to the SAI. I trace the USB communication with a logic analyzer (all zeros) and the received data with the debugger (corrupt data). I created my project with CubeMX and did not change anything in the USB stack. So I think the buffer is in the heap. I also changed it static but with no difference to the received data.

Other interrupts or DMAs are also not used.