I struggle since two weeks (hobby part time) to setup a working example of UAC1.0 USB to I2S - stereo 48kHz 16 bits on a stm32F4 discovery card (with CS43L22 CODEC).
I try to get the project developed as far as possible on existing code from ST:
I already know that the ST software is far from perfect, and that the implementation of Audio has been made overly complex / abstract / inconsistent. So no need to convince me of that fact: I know… I finally convinced that I understood it enough, and could leave with that.
But I don't succeed to get it working, and don't find why. The output is cracks + some part of (not correct) music. I checked with Music, and tests tracks with one stereo channel silent and the other with a 1000 Hz tone. On music, the volume on the streamer has an impact on the result:
It looks like a problem with Buffer/DMA alignment. Channels mismatch, Main and Least significant bytes issues ?
I have the record and playback example working, from USB board. I normally use the same BSP and board drivers code. The I2C and CS42L22 configs are the same. The configuration of the I2S and associated DMA look the same…
In debug mode, I looked at the buffer values, with one channel active and the other with tome, and it looks correct. Pattern of values around 0 for the silent channet (0x00, 0xFF, 0x01…), and logically changing values for the tone.
I tried to modify the Sync function in usbd_audio.c to start playing the music when buffer is half filled instead of when buffer is 100% full and write pointer rollback to zero (which means that the USB is writing in the buffer just ahead of the DMA reading, seems…).
I looks at the HAL_init (mine generated from STM32CubeIDE, the other from the example), and they look similar, except for the prefetch which is enabled in my code, and is not in the ST "record and playback".
Would those symptoms trigger some thought about things to checks, or some corrections to make in the ST code that could result in that?
Help welcomed. Must be a small mistake somewhere that I fail to see…
I also have another issue (hope independent), that when I connect the USB, the board is always seen correctly by the PC (EP0 working OK), I can start music on Foobar and it plays… but EP01 is not receiving data (at least not activated). After 2-3 attempts, then it starts and I get the audio stream activate the DataOut procedure.
Best regards,
JMF11
JMF
I try to get the project developed as far as possible on existing code from ST:
- STM32CubeIDE generated code,
- The board Drivers/BSP code for the audio part.
I already know that the ST software is far from perfect, and that the implementation of Audio has been made overly complex / abstract / inconsistent. So no need to convince me of that fact: I know… I finally convinced that I understood it enough, and could leave with that.
But I don't succeed to get it working, and don't find why. The output is cracks + some part of (not correct) music. I checked with Music, and tests tracks with one stereo channel silent and the other with a 1000 Hz tone. On music, the volume on the streamer has an impact on the result:
- low volume: one channel plays something and nothing on the other
- Higher volume: more tracks and music+cracks seems to apppear on other channel
It looks like a problem with Buffer/DMA alignment. Channels mismatch, Main and Least significant bytes issues ?
I have the record and playback example working, from USB board. I normally use the same BSP and board drivers code. The I2C and CS42L22 configs are the same. The configuration of the I2S and associated DMA look the same…
In debug mode, I looked at the buffer values, with one channel active and the other with tome, and it looks correct. Pattern of values around 0 for the silent channet (0x00, 0xFF, 0x01…), and logically changing values for the tone.
I tried to modify the Sync function in usbd_audio.c to start playing the music when buffer is half filled instead of when buffer is 100% full and write pointer rollback to zero (which means that the USB is writing in the buffer just ahead of the DMA reading, seems…).
I looks at the HAL_init (mine generated from STM32CubeIDE, the other from the example), and they look similar, except for the prefetch which is enabled in my code, and is not in the ST "record and playback".
Would those symptoms trigger some thought about things to checks, or some corrections to make in the ST code that could result in that?
Help welcomed. Must be a small mistake somewhere that I fail to see…
I also have another issue (hope independent), that when I connect the USB, the board is always seen correctly by the PC (EP0 working OK), I can start music on Foobar and it plays… but EP01 is not receiving data (at least not activated). After 2-3 attempts, then it starts and I get the audio stream activate the DataOut procedure.
Best regards,
JMF11
JMF
Hello,
I borrowed a logic analyzer. Setup it for I2S and connected to the board. Iplay a track with silence on one track and a 1000Hz tone on the other.
I ran the working example (Playback and record), and the output is fine: one channel to 0x00, the other with sensible 16 bit values.
Then I ran my code, and the output is clearly wrong. There are variants, but basically, it stammers. Instead of 0x0000, 0xDE1F, 0x0000, 0xCA... it gives something like 0x0000, 0x0000, 0xDEDE, 0xCACA, 0x0000, 0x0000,
However, the buffer from USB looks correct, with altervating 0x00 and filled Words for the oyther channel.
This should help to narrow down the issue, but I still don't have the culprit.
JMF
I borrowed a logic analyzer. Setup it for I2S and connected to the board. Iplay a track with silence on one track and a 1000Hz tone on the other.
I ran the working example (Playback and record), and the output is fine: one channel to 0x00, the other with sensible 16 bit values.
Then I ran my code, and the output is clearly wrong. There are variants, but basically, it stammers. Instead of 0x0000, 0xDE1F, 0x0000, 0xCA... it gives something like 0x0000, 0x0000, 0xDEDE, 0xCACA, 0x0000, 0x0000,
However, the buffer from USB looks correct, with altervating 0x00 and filled Words for the oyther channel.
This should help to narrow down the issue, but I still don't have the culprit.
JMF