Skip to main content
Visitor II
December 5, 2018
Question

Help using MP34DT01 with DFSDM on board microphone on B-L475E-IOT01A1.

  • December 5, 2018
  • 1 reply
  • 2284 views

Hi

I am trying to record audio at 44.1 KHz with the on board microphones on B-L475E-IOT01A1 device, and since the firmware package does not contain DFSDM example for this particular board, I tried adapting the DFSDM example from the STM32L476-DISCOVERY board.

I have got the peripheral working with 2 Channels set up (channel 2 and 1 feeding into filter 0, 1) and I am also getting half and complete regaular conversion Interrupt service routing callbacks, however the audio is all garbled.

Has anyone managed to get this to work on this particular board.

Any help would be greatly appreciated.

Thanks

Subhojit

    This topic has been closed for replies.

    1 reply

    Super User
    December 5, 2018

    Is there no example code for this particular board?

    > the audio is all garbled

    How exactly garbled? How do you "observe" the audio? Can you give some example data? What data do you obtain if you try to use unconnected channels which you pull down or pull up?

    JW

    SSomAuthor
    Visitor II
    December 5, 2018

    Hi

    Thanks for responding. There seems to be no example for this particular board ( B-L475E-IOT01A1), and so I used the DFSM audio record example for the STM32L476-DISCOVERY board as reference.

    I got the audio out of the board through a tcp socket ( after connecting to it to wifi)), and dumped to a a wav file.

    My config is such -

    • channel 1 and channel 2 are activated with SPI clock
    • channel-1 feeds filter0, and chaneel-2 feeds filter 1.
    • regular conversion with DMA enabled.

    Here is my init of channel 2 which gets i/p from PE7 and gives clkout at PE9

    hdfsdm1_channel2.Instance = DFSDM1_Channel2;

    hdfsdm1_channel2.Init.OutputClock.Activation = ENABLE;

    hdfsdm1_channel2.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO;

    hdfsdm1_channel2.Init.OutputClock.Divider = 4;

    hdfsdm1_channel2.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;

    hdfsdm1_channel2.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE;

    hdfsdm1_channel2.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;

    hdfsdm1_channel2.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_FALLING;

    hdfsdm1_channel2.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;

    hdfsdm1_channel2.Init.Awd.FilterOrder = DFSDM_CHANNEL_SINC1_ORDER;

    hdfsdm1_channel2.Init.Awd.Oversampling = 10;

    hdfsdm1_channel2.Init.Offset = 0;

    hdfsdm1_channel2.Init.RightBitShift = 2;

    if (HAL_DFSDM_ChannelInit(&hdfsdm1_channel2) != HAL_OK)

    {

    Error_Handler();

    }

    Similar config for channel 1, as above. Below is filter 1 receiving feed from channel 2

    hdfsdm1_filter1.Instance = DFSDM1_Filter1;

    hdfsdm1_filter1.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER;

    hdfsdm1_filter1.Init.RegularParam.FastMode = ENABLE;

    hdfsdm1_filter1.Init.RegularParam.DmaMode = ENABLE;

    hdfsdm1_filter1.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER;

    hdfsdm1_filter1.Init.FilterParam.Oversampling = 64;

    hdfsdm1_filter1.Init.FilterParam.IntOversampling = 1;

    if (HAL_DFSDM_FilterInit(&hdfsdm1_filter1) != HAL_OK)

    {

    Error_Handler();

    }

    if (HAL_DFSDM_FilterConfigRegChannel(&hdfsdm1_filter0, DFSDM_CHANNEL_1, DFSDM_CONTINUOUS_CONV_ON) != HAL_OK)

    {

    Error_Handler();

    }

    if (HAL_DFSDM_FilterConfigRegChannel(&hdfsdm1_filter1, DFSDM_CHANNEL_2, DFSDM_CONTINUOUS_CONV_ON) != HAL_OK)

    {

    Error_Handler();

    }

    after receiving data into my int32 buffers here is how conversion is being done to int 16:

    SendBuff[2*i]    = (uint16_t)(SaturaLH((LeftRecBuff[i] >> 8), -32768, 32767));

    SendBuff[(2*i)+1] = (uint16_t)(SaturaLH((RightRecBuff[i] >> 8), -32768, 32767));

    SendBuff here is int16 buffer, which is then written on the socket, and LeftRecBuff/RightRecBuff, are int32 buffers where recorded samples are stored.

    I am also attaching a dump of the wav data that I got from the recording.

    Visitor II
    January 17, 2019

    Hi Som,

    Did you manage to fix the problem? Seems like I have the same problem with a software for my custom board. I use same configuration and get

    understandable but distorted sound.