Skip to main content
CLeo.1
Senior II
October 13, 2020
Solved

I2S STM32 Sampling frequency different from what reference manual states, why?

  • October 13, 2020
  • 6 replies
  • 2398 views

Hi Guys, in the reference sheet of the STM32H753ZI Pg. 2212 it says

"FWS is the audio sampling

frequency."

There's a programing example provided at Pg. 2232 that says Sampling Freq = 48kHz.

I tried this exact configuration, the MCLK, FWS, and SCLK are all correct, however when I see the sampling frequency its double of the FW?

The green signal is the On and Off when the DMA triggers. Sample buffer is length of 4

so it will trigger at 2 and 4. High is Complete and Low is Half Complete

Yellow signal is the FWS

0693W000004JWv8QAG.png 

CODE: MAIN()

uint16_t RxBuff[4];
uint16_t TxBuff[4];
uint8_t TC_Callback = 0;
uint8_t HC_Callback = 0;
char uartBuff[8];
void DMA1_Stream0_IRQHandler(void) {
	if (((DMA1 -> LISR) & (DMA_LISR_TCIF0)) != 0){
		DMA1 -> LIFCR |= DMA_LIFCR_CTCIF0;
		TC_Callback = 1;
	}
	else if (((DMA1 -> LISR) & (DMA_LISR_HTIF0)) != 0){
		 DMA1 -> LIFCR |= DMA_LIFCR_CHTIF0;
		 HC_Callback = 1;
	}
 
}
 
int main(void) {
	init_Clock();
	init_I2S();
	init_Debugging();
	init_Interrupt();
	init_SpeedTest();
 while (1)
 {
 
 
 
	 if (HC_Callback == 1){
		 GPIOA->BSRR |= GPIO_BSRR_BS3_HIGH;
		 HC_Callback = 0;
	 } else if (TC_Callback == 1){
 
		 GPIOA->BSRR |= GPIO_BSRR_BR3_LOW;
		 TC_Callback = 0;
	 }
 
 
 }
}

 The math to find out the F_sample (Green Signal)

 Half Complete triggers every 20.6uS for every 2 Samples.

Thus in 1 second 97kSamples are obtained, which is close to 96kSamples and not 48kSamples as it was suggested from the reference manual

UPDATE 1:

I have tried making FWS = 96kHz this caused the sampling frequency to be closed to 192khz so it looks like the sampling frequency for I2S is FWS*2?

This topic has been closed for replies.
Best answer by waclawek.jan

I2S is inherently stereo, so you have 2 data per sample.

JW

6 replies

waclawek.jan
waclawek.janBest answer
Super User
October 13, 2020

I2S is inherently stereo, so you have 2 data per sample.

JW

CLeo.1
CLeo.1Author
Senior II
October 13, 2020

Ahhh, I was under the assumption since I made changes to the "FTHLV" register to be 1 data. So It would only transfer the Left side audio

waclawek.jan
Super User
October 21, 2020

I don't use the 'H7 and the SPI/I2S module there is a beast, but, AFAIK, FTHLV impacts only the "inward" SPI/I2S-to-processor interface, not the "outward" behaviour of the "protocol interface".

JW

CLeo.1
CLeo.1Author
Senior II
October 21, 2020

Ahh thank you. I was curious if you could help me out on another question I posted here, Its about the Digital filter implementation via matlab to STM32H7

waclawek.jan
Super User
October 22, 2020

Sorry, I am neither into Matlab nor 'H7.

JW

CLeo.1
CLeo.1Author
Senior II
October 22, 2020

Its fine, I figured it out I was at the wrong sampling rate. So The new issue is that I am making my FWS back to 48kHz now the I2S peripherals doesn't want to send data to the MCU but if I use FWS = 96kHz it works perfect? Any thoughts?