AnsweredAssumed Answered

Bug in stm32f4 Audio playback and recording ?!

Question asked by s.esat on Apr 25, 2013
Latest reply on Jun 20, 2013 by sheehy.rosemarie
Hello ;
In the recording example in teh discovery board we have this code :
if(Data_Status==1)
{
Data_Status=0;
      
      
     /* Switch the buffers*/
      if (Switch ==1)
     {
       pAudioRecBuf = RecBuf;
       writebuffer = RecBuf1;
       WaveCounter += 32;
       Switch = 0;
     }
      else
      {
        pAudioRecBuf = RecBuf1;
        writebuffer = RecBuf;
        WaveCounter += 32;
        Switch = 1;
      }
        
      for (counter=0; counter<16; counter++)
      {
        
        if (buf_idx< RAM_BUFFER_SIZE)
        {
          /* Store Data in RAM buffer */
          RAM_Buf[buf_idx++]= *(writebuffer + counter);
          if (buf_idx1 == RAM_BUFFER_SIZE)
          {
                  
            buf_idx1 = 0;
            /* Write the stored data in the RAm to the USB Key */
            f_write (&file, (uint16_t*)RAM_Buf1, RAM_BUFFER_SIZE*2 , (void *)&bytesWritten);
          }
        }
        else if (buf_idx1< RAM_BUFFER_SIZE)
        {
          /* Store Data in RAM buffer */
          RAM_Buf1[buf_idx1++]= *(writebuffer + counter);
          if (buf_idx == RAM_BUFFER_SIZE)
          {
                              
            buf_idx = 0;
            /* Write the stored data in the RAM to the USB Key */
           f_write (&file, (uint16_t*)RAM_Buf, RAM_BUFFER_SIZE*2 , (void *)&bytesWritten);
          }
        }
      }   
  
  
        }
  
}
I believe RAM_Buf1 stores the wrong data and all the time RAM_Buf only been used , Please check it


Regards
Esat

Outcomes