cancel
Showing results for 
Search instead for 
Did you mean: 

example with analog microphone crashes on STM32F412G-Discovery

PCu1
Senior

Hello, 

I'm trying to do a quick test with the STM32F412G-Discovery kit and the analogue microphone input.
I use this example https://github.com/STMicroelectronics/STM32CubeF4/tree/master/Projects/STM32F412G-Discovery/Examples/BSP

with the menu #### AUDIO REC ANALOG ####.

The problem is that the firmware crashes at the line BSP_AUDIO_IN_Record(internal_buffer, AUDIO_BLOCK_SIZE);

 

void AudioRecAnalog_demo (void)
{
  AudioRec_SetHint();

  /* Initialize Audio Recorder */
  if (BSP_AUDIO_IN_InitEx(INPUT_DEVICE_ANALOG_MIC, DEFAULT_AUDIO_IN_FREQ, DEFAULT_AUDIO_IN_BIT_RESOLUTION, DEFAULT_AUDIO_IN_CHANNEL_NBR) == AUDIO_OK)
  {
    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"  AUDIO RECORD INIT OK  ", CENTER_MODE);
  }
  else
  {
    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
    BSP_LCD_SetTextColor(LCD_COLOR_RED);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"  AUDIO RECORD INIT FAIL", CENTER_MODE);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 80, (uint8_t *)" Try to reset board ", CENTER_MODE);
  }

  audio_rec_buffer_state = BUFFER_OFFSET_NONE;

  /* Display the state on the screen */
  BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
  BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 80, (uint8_t *)"       RECORDING...     ", CENTER_MODE);


  /* Start Recording */ crash here
  BSP_AUDIO_IN_Record(internal_buffer, AUDIO_BLOCK_SIZE);

  /* Wait end of one block recording */
  while((audio_rec_buffer_state & BUFFER_OFFSET_FULL) != BUFFER_OFFSET_FULL);

  /* Stop recorder */
  BSP_AUDIO_IN_Stop();

 

Does anyone have an idea?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

Hello,

An update from the internal team saying that the issue is in BSP_AUDIO_IN_InitEx(uint32_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) which doesn't properly stop the DMA channel after configuring the audio codec and setting the parameters of the I2S3 peripheral. Since the DMA isn't properly disabled, it doesn't properly store the recorded data later in the buffer, and that's why the transfer isn't accomplished, and the example crushes at this stage.

This will be fixed in the coming revision of the Cube.

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
mƎALLEm
ST Employee

Hello,

Internal ticket 195718 for follow up and confirmation of the issue / fix if there is one ..

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

FYI,

Behavior reproduced internally. Analysis is ongoing.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
mƎALLEm
ST Employee

Hello,

An update from the internal team saying that the issue is in BSP_AUDIO_IN_InitEx(uint32_t InputDevice, uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr) which doesn't properly stop the DMA channel after configuring the audio codec and setting the parameters of the I2S3 peripheral. Since the DMA isn't properly disabled, it doesn't properly store the recorded data later in the buffer, and that's why the transfer isn't accomplished, and the example crushes at this stage.

This will be fixed in the coming revision of the Cube.

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.