Skip to main content
Associate II
April 5, 2026
Question

STM32H743 usb_audio_device, wrong channel mapping for channel 3 and 4

  • April 5, 2026
  • 3 replies
  • 248 views

Hi community.

TLV230adc5140 - SAI 4CH(TDM) - STM32 - USB_FS_ 4CHmic - Window(LInux RP5) 

I reuse partly code from memsmic1 project to create 4 microfone audio device. Everything look well for channel 1 and 2 I got some trouble whit CH3 and CH4.  Please help whit    wrong channel mapping for channel 3 and 4. It is mapped on channel  1 and 2  on usb interface. One can see it on attached picture. Here is TLV switched off, SAI(DMA call back) reused for 4 sin generator 1,2,3,4 kHz for every supposed channel. Here you see the picture.

Where i  am wrong?   

 

Capture.JPG

3 replies

Associate II
April 5, 2026

photo_2026-04-06_01-26-42.jpg

here is better quality picture. 

Technical Moderator
April 6, 2026

Hello @Dmitriy_777 

To better understand and reproduce the issue, could you provide a bit more information? Which reference board are you using? Are you using latest version? 

Otherwise, it would be very helpful if you could share a minimal project that reproduces the 4‑channel mapping problem. This would allow us to analyze the configuration and escalate the issue if needed.

 
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
Associate II
April 6, 2026

Hi FBL

Thank you for answer.

I've tried to clean up the code as much as possible. I kept the sine wave generator, the audio initialization and callback functions, and a modified usbd_audio_in.c adapted for static buffers. Unfortunately, the STM version with dynamic filling didn't work out

1) Main.c ------ static void fill_usb_sine_1khz_ch4(int16_t *buf) + (ADC5140_Start_Record((uint16_t*)audio_buffer, RECORD_BUF_SIZE) != HAL_OK) + while(1)

2) tlv320adc5140.c --- 

HAL_StatusTypeDef ADC5140_Start_Record, void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai),

void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)

 

3) usbd_audio_if.c --- void Send_Audio_to_USB(int16_t *audioData, uint16_t PCMSamples)

 

4) static uint8_t USBD_AUDIO_Init, static uint8_t USBD_AUDIO_DataIn,uint8_t USBD_AUDIO_Data_Transfer

 

Please build the project, check the 'Listen to this device' box in Windows settings, and run the debug procedure a couple of times. It didn't launch on the first attempt.

Associate II
April 8, 2026
 

Hi FBL

 

we got result. please stop guys. i resolve 4 channel task   

 

Tank you so much.4_channel_good.JPG

Technical Moderator
April 13, 2026

Hello  @Dmitriy_777 

Thank you for your feedback

So the root cause, wChannelConfig was still set for stereo instead of 4 channels. USB Audio middleware and sample code for STM32 generally support stereo (2-channel) configurations by default. User need to configure it manually. Configuration for multi-channel streaming requires both hardware and firmware modifications.

Linux is often more tolerant of USB audio descriptor oddities than Windows.
So if the stream data and packet size are already correct, Linux may still record successfully even when wChannelConfig is not ideal.

About the second issue, it's highly recommended to start new discussion to address this issue. The behavior is likely related to USB disconnect / reconnect handling.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL