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-09-25 8:07 AM
Hello @Jinal
To help us further investigate the sampling frequency mismatch, could you please share the configuration details of your SAI kernel clock? For accurate 44.1 kHz audio output, the SAI kernel clock should be set to a frequency that is multiple of 44.1 kHz.
2025-09-30 11:20 AM
Hi @Saket_Om
Thanks for your response. My clock configuration is shown in the image, and I’ve attached the IOC file for reference. Appreciate your support!
Thanks,
Jinal
2025-10-01 3:10 AM
Hello @Jinal
Could you try with the flowing config please.
In this config the SAI kernel clock is around 11.294 which is nearly multiple of 44.1 Khz.
2025-10-07 7:14 AM - edited 2025-10-07 7:15 AM
Hi @Saket_Om
Thanks for response,
I configured the SAI kernel clock as per your suggestion, and the audio output is now slightly clearer.
When we play a mono-converted audio file using the existing configuration, the sound quality has improved — it’s more audible, though still not perfect.
Could you please suggest the recommended configuration for mono audio playback?
Thank you
Jinal
2025-10-07 7:37 AM
Hello @Jinal
The ideal is to use an external SAI clock with an output frequency exactly multiple of 44.1 Khz.
2025-10-08 12:20 AM
Hi,
As per your suggestion, we made the changes and the clock now appears almost the same. However, the audio is still noisy.
Could you please suggest the correct mono mode configuration so that we can test the mono audio file with it?
2025-10-13 6:16 AM
Hi @Saket_Om
I played the same audio using the EVK’s onboard MCU, and the output was clean (no noise or distortion) with the same configuration. However, when using the STM setup, the audio is noisy. Could you please suggest if I might be missing any configuration settings?
Thanks
Jinal
2025-10-13 6:45 AM
Hi,
sure about :
Init.Protocol = SAI_FREE_PROTOCOL;
...as from ds, TAS2110 expects I2S protocol (if not set to other) ?
2025-10-13 6:52 AM
Hello @Jinal
The issue might be related to the audio codec configuration. Please make sure that the TAS2110 is being configured correctly.