cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 DISCO data transfer

matas
Associate II
Posted on September 30, 2015 at 15:31

I want to pass data from MP45DT02 MEMS mic  to the audio DAC CS43l22. All the configurations seems okay, the thing I can't seem to achieve is the correct Fifo buffer. The FIFO read variable (which points to the next array element to read) seems to always catch up to the FIFO write variable (the next array element to write to). Here my FIFO read and FIFO write functions:

void FIFO_add(uint16_t element){

  if(Fifo_write + 1 != Fifo_read){

    

    FiFo_buffer[Fifo_write] = element;

    

    if(Fifo_write == 31){

      

      Fifo_write = 0;

      

    }else{

      

      Fifo_write++;

      

    }

  } 

}

 

 uint16_t FIFO_remove(){

   

   uint16_t output;

   if(Fifo_read+1 != Fifo_write){

     output = FiFo_buffer[Fifo_read];

     if(Fifo_read == 31){

       

      Fifo_read = 0;

      

     }else{

     

       Fifo_read++;

       

     }

     

     return output;

   }else{

     output = 0; 

     return output;

   

   }

   

 }

what do you think? i keep hearing a lot of screaching on the audio output (and my voice in the background).

I tested the DAC with a PCM array which played music as it supposed to. So DAC is really ok.

#stm32f4 #mems #mp45dt02
3 REPLIES 3
Posted on September 30, 2015 at 17:56

Buffer seems a bit shallow, but I don't really understand the flow rates in your situation

This test looks to be broken at the wrapping condition

if(Fifo_write + 1 != Fifo_read)

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
matas
Associate II
Posted on October 03, 2015 at 19:10

Thanks, I replaced it with another way to pass data. Everything seems running okay now with one microphone. Now I want to move forward and attach a second one to catch stereo sound, but a funny thing happens as the MEMS microphone datasheet indicates, to attach a second microphone all you have to do is to set up the L/R pin in MIC nr. 1 GND and for MIC nr. 2 VDD, all other connections are shared (Clock, Data). When I connect the second Mic to PB10 (CLK) and PC3 (Data) the program only catch the microphone with grounded L/R pin. I checked it by grounding both microphones and the output was trashy, yet both microphones were sensitive.

So all in all, If the L/R pin of an external mems MIc is high, the Mic is ignored. So is there a setting which I have to change, because, I can't seem to find it. And I tried changing up the frequencies, but that also doesn't help.

matas
Associate II
Posted on October 03, 2015 at 20:47

I have found the mistake, it catches the samples of one microphone, depending on the selected I2S standard. If the standard is uses rising edges to separate samples (Philips, MSB, LSB protocols) it catches the MIC with grounded L/R, if I use PCM protocol it catches only the one with the High L/R, so how to get them both? :D Switch between protocols, can't be right.