cancel
Showing results for 
Search instead for 
Did you mean: 

STM32429I-EVAL - Re-purpose stdperiph SAI_Audio example to use microphone.

thomas2
Associate II
Posted on February 10, 2014 at 15:07

Hi,

So I've recently started developing on the 'STM32429I-EVAL', I've managed to compile and run the SAI_Audio example which outputs an audio sample to the headphones. I'm now trying to stream one of the two built-in microphones to the headphone jack, with little success.

My understanding of SAI is that it connects all the audio related peripherals to the on-board codec. After reading the user manual and datasheet, I can confirm the twin microphones are connected to the codec. (I can either connect them to the codec or I2S via jumpers)

However, when I pass in the SAI memory address into the play function instead of the example audio sample, I hear white noise. 

'EVAL_AUDIO_Init(OUTPUT_DEVICE_HEADPHONE, uwVolume, SAI_AudioFreq_44k)'

'EVAL_AUDIO_Play((uint16_t*)CODEC_SAI_ADDRESS, 32);'

(CODEC_SAI_ADDRESS is set to, (uint32_t)(&SAI1_Block_B->DR) )

In the stm324x91_eval_audio_codec.h file I've changed the active SAI slot, set the PLL clock to SAI and set the Audio Transfer mode to AUDIO_MAL_MODE_CIRCULAR. - Which I believe is used for setting up the DMA.

I have noticed that when debugging, the DMA transfer complete interrupt is only called once. Even in circular mode. Calling EVAL_AUDIO_Play within the interrupt doesn't appear to re-trigger it.

void EVAL_AUDIO_TransferComplete_CallBack(uint32_t pBuffer, uint32_t Size)

{

  /* Calculate the remaining audio data in the file and the new size 

     for the DMA transfer. If the Audio files size is less than the DMA max 

     data transfer size, so there is no calculation to be done, just restart 

     from the beginning of the file ... */

  /* Check if the end of file has been reached */

STM_EVAL_LEDToggle(LED4);

EVAL_AUDIO_Play((uint16_t*)CODEC_SAI_ADDRESS, 32);

}

Have I missed any important steps? Any tips on working with SAI peripherals would be greatly appreciated. Thank you.

1 REPLY 1
thomas2
Associate II
Posted on February 12, 2014 at 13:22

So I'm using a scope to measure the data signals that 'should' be passing through JP14 from the microphones, there doesn't appear to be any pattern on the data or clock lines. The lines appear silent. I'm sort of stumped as to what to try next.

The stm324x9i_eval_audio_codec offers 3 clocks, I've made sure to select SAI_ClockPLLSAI, which I assume runs the DMICCLK clock output on the codec (the one which I'm trying to read with the scope).

The SAI clock is configured as follows:

  /* Configure PLLSAI prescalers */

  /* PLLSAI_VCO : VCO_429M */

  /* SAI_CLK(first level) = PLLSAI_VCO/PLLSAIQ = 429/2 = 214.5 Mhz */

  RCC_PLLSAIConfig(429, 2, 4);

  /* SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ = 214.5/19 = 11.289 Mhz */  

  RCC_SAIPLLSAIClkDivConfig(19);

  /* Configure Clock source for SAI Block A */

  RCC_SAIBlockACLKConfig(RCC_SAIACLKSource_PLLSAI);

/* Enable PLLSAI Clock */

  RCC_PLLSAICmd(ENABLE);

//Stream from the microphones

EVAL_AUDIO_Play((uint16_t*)CODEC_SAI_ADDRESS, 16);

I've tried using I2S instead of SAI but no luck in that regard. Am I right in thinking I should only use I2S if I want to pipe the data from an audio source to somewhere other than into the codec? Currently I'm simply trying to relay the microphone input directly to the headphone output. I've also noticed that even in DMA circular mode and recalling the codec 'play' function inside the Transfer Complete callback (with it enabled), that the call back only ever seems to occur once, could this be why I'm hearing static? 

Apologies for the barrage of questions, I'm new to DSP and audio processing in general. Thanks in advance.