2026-04-05 3:25 PM
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?
2026-04-05 3:28 PM
here is better quality picture.
2026-04-06 2:04 AM
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.
2026-04-06 4:13 AM
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.
2026-04-06 4:15 AM
2026-04-06 2:36 PM
it look like 4 ch going well. linux also see card but do not what to record.
2026-04-08 1:40 PM
Hi FBL
we got result. please stop guys. i resolve 4 channel task
Tank you so much.
2026-04-09 3:00 AM
Hi @Dmitriy_777
Thank you for your feedback
Can you explain the workaround proposed to solve this issue?
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.
2026-04-12 4:45 AM
Hi FBL.
Sure. it was here + SAI interface settings playing.
2026-04-13 3:56 AM
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.