2025-09-18 9:43 AM - last edited on 2025-09-25 6:42 AM by Saket_Om
Post edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code
Hi,
On checking, I noticed a mismatch between the expected sampling frequency (44.1 kHz) and the actual frequency (46.875 kHz). Could this be the cause of the noise? Any suggestions on what might be going wrong?
For reference, I’m using SAI1_A with circular linked-list channel 12 of GPDMA1. The configuration details for SAI and GPDMA are provided below.
GPDMA Configuration:
handle_GPDMA1_Channel12.Instance = GPDMA1_Channel12;
handle_GPDMA1_Channel12.InitLinkedList.Priority = DMA_HIGH_PRIORITY;
handle_GPDMA1_Channel12.InitLinkedList.LinkStepMode = DMA_LSM_FULL_EXECUTION;
handle_GPDMA1_Channel12.InitLinkedList.LinkAllocatedPort = DMA_LINK_ALLOCATED_PORT0;
handle_GPDMA1_Channel12.InitLinkedList.TransferEventMode = DMA_TCEM_LAST_LL_ITEM_TRANSFER;
handle_GPDMA1_Channel12.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;
SAI Configuration:
hsai_BlockA1.Instance = SAI1_Block_A;
hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL;
hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_TX;
hsai_BlockA1.Init.DataSize = SAI_DATASIZE_16;
hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB;
hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;
hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS;
hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE;
hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF;
hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_44K;
hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
hsai_BlockA1.Init.MckOutput = SAI_MCK_OUTPUT_DISABLE;
hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE;
hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING;
hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED;
hsai_BlockA1.Init.PdmInit.Activation = DISABLE;
hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1;
hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;
hsai_BlockA1.FrameInit.FrameLength = 32;
hsai_BlockA1.FrameInit.ActiveFrameLength = 16;
hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION;
hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;
hsai_BlockA1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT;
hsai_BlockA1.SlotInit.FirstBitOffset = 0;
hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE;
hsai_BlockA1.SlotInit.SlotNumber = 2;
hsai_BlockA1.SlotInit.SlotActive = 0x00000003;
LinkList configuration:
pNodeConfig.NodeType = DMA_GPDMA_LINEAR_NODE;
pNodeConfig.Init.Request = GPDMA1_REQUEST_SAI1_A;
pNodeConfig.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
pNodeConfig.Init.Direction = DMA_MEMORY_TO_PERIPH;
pNodeConfig.Init.SrcInc = DMA_SINC_INCREMENTED;
pNodeConfig.Init.DestInc = DMA_DINC_FIXED;
pNodeConfig.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_HALFWORD;
pNodeConfig.Init.DestDataWidth = DMA_DEST_DATAWIDTH_BYTE;
pNodeConfig.Init.SrcBurstLength = 1;
pNodeConfig.Init.DestBurstLength = 1;
pNodeConfig.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0|DMA_DEST_ALLOCATED_PORT0;
pNodeConfig.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
pNodeConfig.TriggerConfig.TriggerPolarity = DMA_TRIG_POLARITY_MASKED;
pNodeConfig.DataHandlingConfig.DataExchange = DMA_EXCHANGE_NONE;
pNodeConfig.DataHandlingConfig.DataAlignment = DMA_DATA_RIGHTALIGN_ZEROPADDED;
pNodeConfig.SrcAddress = 0;
pNodeConfig.DstAddress = 0;
pNodeConfig.DataSize = 0;
Thanks,
Jinal
2025-10-14 7:55 AM - edited 2025-10-14 7:55 AM
I have verified the TAS2110 configuration, and it looks correct.
I also tried using both I²S and PCM protocols, but the audio output is still noisy.
I captured the output waveform from both the TAS2110EVM (with XMOS MCU) and the STM32 setup, and I noticed that the waveforms are different. Could you please review the attached waveforms and help identify the possible cause of this issue?
PFA the waveform captures from both MCUs.
Thanks,
Jinal
2025-10-14 8:47 AM
What is this ?
Show a png or jpeg - if you want, i can see it.
2025-10-14 9:36 AM
Hi @AScha.3 ,
I’ve shared the .sal files, which can be opened using a logic analyzer.
I’ll also share waveform snapshots for your reference.
Thanks,
Jinal
2025-10-14 10:24 AM - edited 2025-10-14 10:35 AM
Ok,
so just from look at the pics:
- STM I2C looks as expected, I2S , 44k1, stereo , no data, maybe just 00 and FF
- XMOS is some DSP / PCM format , 48k , mono , some data
So if your TAS2110 sounds ok with the XMOS, then you have to
a: adjust the TAS2110 to I2S standard , stereo
or
b: adjust on STM something similar to PCM for DSP, Ti format (afair).
2025-10-28 7:30 AM
We’ve verified the configuration, and it seems the issue is related to the clock and FSYNC signals.
On the XMOS side, the bit clock is 12 MHz with a 48 kHz sample rate and a 256 ratio.
However, on the STM32 side, we’re unable to achieve the same 256 ratio configuration.
Could you please share the correct TDM configuration settings required on the STM32 side to match this setup?
Thanks,
Jinal
2025-10-28 10:10 AM
Hi @Jinal ,
so adjust the clock for SAI to 256 or 512 x Fs ; ...until "real" matches (close) the desired Fs;
see on my H743 clock tree:
+ adjust settings, as i wrote ->
a: adjust the TAS2110 to I2S standard , stereo
or
b: adjust on STM something similar to PCM for DSP, Ti format (afair).
2025-10-28 10:28 AM
Hi @AScha.3
Thanks for your response.
We have configured the clock to closely match the XMOS setup, but the issue seems to be with the ratio of SCLK/FSYNC.
On the XMOS side, the ratio is set to 256 with an SCLK of 12 MHz, but on the STM32 side, we are unable to achieve the same 256 ratio.
When we try setting the SCLK to 12 MHz on STM32, the FSYNC signal does not function correctly.
We also tried bridging the I²S connection using the XMOS configuration, but the audio is still not clear. This indicates that we likely need to match the ratio configuration used by XMOS, but we’re currently unable to set it on STM32.
Could you please suggest how we can configure STM32 to mimic the TDM mode while using I²S?
Thanks,
Jinal
2025-10-28 11:49 AM
>the ratio is set to 256 with an SCLK of 12 MHz
Thats not important, to have 256; you need to set, what the SAI needs, with your setting. (Fs, bits/frame, etc.)
As seen in my last post, i set it to 256x Fs, to get 44,1k .
And 12M is no audio clock, maybe 12.288 M , is 256 x 48k Fs.
So first decide, what you want : 48k or 44k1 .
What all this should be ? A digital amp (TASxxx) with input from...PC ? or what else ?
2025-10-29 12:51 AM
Hi @AScha.3
We are targeting a 48 kHz sampling rate, with the audio data sourced from the on-board flash memory, where the WAV file is stored. The playback data is transmitted from the STM32 MCU to the TAS2110 audio amplifier via the SAI interface configured in I²S mode.
Our goal is to achieve the same audio quality as observed with the TAS2110EVM (XMOS-based TDM configuration with PC input). However, we are currently observing audible noise and distortion when playing the same audio file through the STM32 setup (flash-based input).
Could you please suggest what additional parameters or clock configurations we should verify or adjust to ensure proper I²S operation and cleaner audio output?
Thanks,
Jinal
2025-10-29 3:05 AM
Maybe you have some problem not with the SAI or clocks, but with loading from flash, and / or buffering, and / or DMA ?
Have you checked the output with a simple sine / triangle / square wave from SRAM ?