2026-01-08 7:07 PM
Hello,
I have a PCB with two microphones (IM66D132HV01) with an STM32U575RGT6 (64pin) micro.
Both microphones are connected (L+R) to a single input {PC0, PC2} = {MDF1_SDI4, MDF1_CCK1}
Firstly I cannot find any example code that produces output samples in the MDF1_Filter3->DFLTDR, MDF1_Filter4->DFLTDR data registers -- they are always zero.
I can get the MCU to produce a clock signal and I can see a data bit stream coming to the MCU, from the microphones.
As I was a bit stuck, I resorted to using CubeMX to hopefully get some working code --- however -- with CubeMX the common clock was no longer visible.
I also notcied that if I set up MDF1_F3, and MDF1_F4, that I cannot tell CUBEMX that actually I only need the 'MDF1_SDI4' input since the two filters share the same MDF1_SDI4 bus (one outputs on low clock, the other on high).
Also, I'm looking for some sample code that can give me interrupts for each of the left and right samples, as they are generated by the filter or some advice on how to confirm the serial bitstream is valid etc
Nick.
Solved! Go to Solution.
2026-02-09 5:47 AM
Hello @Nicholas Parker
Sorry for the late reply. I need some further clarifications to help you.
@Nicholas Parker wrote:
[...]
Firstly I cannot find any example code that produces output samples in the MDF1_Filter3->DFLTDR, MDF1_Filter4->DFLTDR data registers -- they are always zero.
I can get the MCU to produce a clock signal and I can see a data bit stream coming to the MCU, from the microphones.
[...]
What do you mean? Are you referring to a not working demo/source code from ST? If so, give me the reference, and I can try to help you. If instead you’re writing some code on your own, it will be hard to debug it, but you can share here the initialization procedure, screenshots from your debugging sessions, ...
A further note: if you’re seeing the data stream coming, it means that you set the MDF clock correctly. At least, the clock is valid for the MEMS microphone you’re addressing. Is this data stream meaningful?
@Nicholas Parker wrote:
[...]
As I was a bit stuck, I resorted to using CubeMX to hopefully get some working code --- however -- with CubeMX the common clock was no longer visible.
I also notcied that if I set up MDF1_F3, and MDF1_F4, that I cannot tell CUBEMX that actually I only need the 'MDF1_SDI4' input since the two filters share the same MDF1_SDI4 bus (one outputs on low clock, the other on high).
[...]
Can you check with this configuration?
The common clock must be selected in the "Mode" window (is the very last parameter), then you'll be able to select "SITF with Common Clock..." as a source.
I know it’s a bit annoying, but in the "Configuration" window CubeMX requires you to select the front selection nevertheless the parameter description above suggest that both fronts can be used.
So, agree with you that there’s a limitation in the tool and that both fronts can be used to trigger audio data from 2 different MEMS microphones.
@Nicholas Parker wrote:
[...]
Also, I'm looking for some sample code that can give me interrupts for each of the left and right samples, as they are generated by the filter or some advice on how to confirm the serial bitstream is valid etc
Nick.
You can have a look into FP-SNS-STBOX1 or FP-SNS-DATALOG2. Both packages support 2 STEVAL boards mounting STM32U5 microcontroller + MEMS microphones: STEVAL-MKBOXPRO and STEVAL-STWINBX1. Both function packs are distributing the BSP drivers containing the related xxx_audio.c/.h files with the MDF configurations and acquisition callback.
You can have a look here and search for the HAL_MDF_AcqCpltCallback function. This function is called by the MDF interrupt and it processes the signal to get the final audio stream. Here, the BSP is setting the peripheral to get an interrupt each millisecond.
I wish all those hints can help you.
Best regards,
Simone
2026-02-09 5:47 AM
Hello @Nicholas Parker
Sorry for the late reply. I need some further clarifications to help you.
@Nicholas Parker wrote:
[...]
Firstly I cannot find any example code that produces output samples in the MDF1_Filter3->DFLTDR, MDF1_Filter4->DFLTDR data registers -- they are always zero.
I can get the MCU to produce a clock signal and I can see a data bit stream coming to the MCU, from the microphones.
[...]
What do you mean? Are you referring to a not working demo/source code from ST? If so, give me the reference, and I can try to help you. If instead you’re writing some code on your own, it will be hard to debug it, but you can share here the initialization procedure, screenshots from your debugging sessions, ...
A further note: if you’re seeing the data stream coming, it means that you set the MDF clock correctly. At least, the clock is valid for the MEMS microphone you’re addressing. Is this data stream meaningful?
@Nicholas Parker wrote:
[...]
As I was a bit stuck, I resorted to using CubeMX to hopefully get some working code --- however -- with CubeMX the common clock was no longer visible.
I also notcied that if I set up MDF1_F3, and MDF1_F4, that I cannot tell CUBEMX that actually I only need the 'MDF1_SDI4' input since the two filters share the same MDF1_SDI4 bus (one outputs on low clock, the other on high).
[...]
Can you check with this configuration?
The common clock must be selected in the "Mode" window (is the very last parameter), then you'll be able to select "SITF with Common Clock..." as a source.
I know it’s a bit annoying, but in the "Configuration" window CubeMX requires you to select the front selection nevertheless the parameter description above suggest that both fronts can be used.
So, agree with you that there’s a limitation in the tool and that both fronts can be used to trigger audio data from 2 different MEMS microphones.
@Nicholas Parker wrote:
[...]
Also, I'm looking for some sample code that can give me interrupts for each of the left and right samples, as they are generated by the filter or some advice on how to confirm the serial bitstream is valid etc
Nick.
You can have a look into FP-SNS-STBOX1 or FP-SNS-DATALOG2. Both packages support 2 STEVAL boards mounting STM32U5 microcontroller + MEMS microphones: STEVAL-MKBOXPRO and STEVAL-STWINBX1. Both function packs are distributing the BSP drivers containing the related xxx_audio.c/.h files with the MDF configurations and acquisition callback.
You can have a look here and search for the HAL_MDF_AcqCpltCallback function. This function is called by the MDF interrupt and it processes the signal to get the final audio stream. Here, the BSP is setting the peripheral to get an interrupt each millisecond.
I wish all those hints can help you.
Best regards,
Simone
2026-02-09 11:12 AM
Thanks for the reply Simone. The common clock issue was perplexing initially - I understand that particular idiosyncrasy of the CubeMX now. I was able to get one of the DMA based examples working. I think an example where there is a 'interrupt per pair of L+R samples' (less efficient I know) would be valuable to have available (if one doesnt exist). I would have gone for that kind of example if it was available rather than struggle through the initial information overload of the DMA and linked lists setup -- on which I still dont have a full understanding. I guess its just more time and reading!
Thanks, Nick