cancel
Showing results for 
Search instead for 
Did you mean: 

AUDIO RECORD - MEMS > DFSDM > I2S > FATFS > Ethernet

Zaher
Senior II

Hello everyone,

I'm trying to implement an audio acquisition system based on some demos from ST's CubeHAL libs. I'm using the STM32F413-Discovery board as a target for this project. It has most of the peripherals needed to complete the job, LCD, MEMS, audio codec, ext. PSRAM, etc.

The MEMS is interfaced through the DFSDM peripheral. I did not use that peripheral before because it was not available in other devices I have used in previous projects. I wanted to implement an audio recorder that can take audio input from the MEMS mounted on board and save that to a file. I noticed that in other board where the MEMS is interfaced to I2S, the PDM2PCB library is used to convert the samples into PCM data. The audio_rec_dfsdm demo seems to do the job without the conversion. Does that mean the output from the DFSDM is directly saved into the SRAM buffer as PCM data?

The live streaming/playback demo seems a great starting point for my project, but the audio/application state machine for the demo code is very complicated and difficult to absorb. I was wondering if there's any other demos, projects, or reference code that I can build upon to do the project. Also, it would be very helpful if someone could explain to me in pseudo code how to do this in RTOS context. I'm talking here about threads, queues, DMA transactions, and their relationship with the application using the FreeRTOS. And when streaming the audio over the network in real-time, Ethernet to another board, do you suggest using an encoder/decorder or just stream the PCM data and have it played back at the other side using I2S and audio codec?

Thanks,

Zaher

2 REPLIES 2
Zaher
Senior II

*** UPDATE ***

OK, I have referred to certain demos and application notes and found out that the conversion from PDM to PCM is not necessary for devices incorporating the DFSDM peripheral.

I'm now trying to understand the Audio_MP3 demo project for the STM32F469I-Discovery board. Could someone tell me why the EXTI0 line is used as a source of interrupt to fill the audio buffer? What follows is the interrupt handler for EXTI0:

void EXTI0_IRQHandler(void)
{
  uint32_t is_swi=0;
 
  /* Detect if it is an SWI on EXT0 line */
  is_swi = (EXTI->SWIER & 0x00000001u) != 0 ;
 
  /* Clear interrupt flag (ie pending bit on EXT0 line)*/
  EXTI->PR = EXTI_PR_PR0_Msk;
 
  if ( is_swi )
  {
    SWI_EXTI0_Callback();
  }
  else
  {
    while(1);
  }
 
}

 And here is the callback function:

/**
* @brief  SWI EXTI0 line detection callback.
*         Loop1: processing to fill MemPool with Buffer1 after USB key file read
* @retval None
*/
void SWI_EXTI0_Callback(void)
{
  /* Debug */
  status_IT1=1;
 
  /* Loop1 processing*/
  UsbToMemPool();
 
  /* Debug */
  status_IT1=0;
 
}

Zaher
Senior II

Someone might find this helpful if they are running into the same issue on the STM32F413 discovery board. Writing on the uSD card directly or using FATFS didn't work while the DFSDM audio capture is active. I spent a few days until I figured it out. Turns out the DFSDM and the uSD TX are using the same DMA stream. Referring to the reference manual of the device, the DMA2 Requests Mapping Table shows that the default streams for SDIO peripheral are Stream3 and Stream6 while other channels/streams might be allocated to the DFSDM. I changed the channel/stream numbers for the DFSDM, as well as its IRQ, and IRQ Handler, and now everything works out perfectly!