cancel
Showing results for 
Search instead for 
Did you mean: 

How to use pdm2pcm library in STM32CubeIDE project?

HTD
Senior III

I have the STM32H745I-DISCO board for tests.

I want to achieve a simple thing: play 1KHz sine wave over the speaker output of the board.

As I researched the subject I found in the documentation:

"Two external speakers can be connected to WM8994ECS/R via JP5 for the right

speaker and JP2 for the left speaker"

Good.

Then, the WM8994 chip can be accessed via SAI / I2S.

I've seen https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H745I-DISCO/Examples/SAI/SAI_AudioPlayback

I don't know how to run it. The example requires IDEs I don't have and I'm not familiar with. However, looking at the sources, I see it uses PDM2PCM Middleware.

I just tried to add it to my STM32CubeIDE project. Of course, the CubeIDE failed to generate the configuration dumping mx.scratch file.

Looking at the file I figured out I need to add following include paths:

  • ../../../Middlewares/ST/STM32_Audio/Addons/PDM/Inc
  • ../../../CM7/PDM2PCM/App

And the link to CM7\PDM2PCM\App and Middlewares\ST\STM32_Audio directories.

When I try to build the project now, I get "pdm2pcm.c:47: undefined reference to `PDM_Filter_Init'" error.

The function is declared by the pdm2pcm_glo.h file, that is properly included.

There is no ".c" file with definitions anywhere.

However, there is a file "libPDMFilter_CM7_GCC_wc32.a". The file seems to be a binary, I guess it's a compiled version of the library containing the missing functions.

If I guessed correctly, I need to tell the IDE somehow to use that file. I don't know how.

The file appears in the project tree.

I tried to use MCU G++ Linker / Libraries settings to add the file, but when I put the file name there - the IDE throws another error it can't find the file. I tried to add the path to the file to the Library Search Path section. Didn't help. I put full absolute path to the file - same result - I get the error the file can't be found.

I'm looking for any help to make this middleware work in my project, also, any information on how to just play anything through the discovery board speaker output.

I'm struggling with 2 kind of problems here: STM32CubeIDE not working properly (that is probably a bug, that is way beyond my level of expertise to fix or workaround) and lack of information / documentation of just how generally it works, how can I use the firmware provided by ST to just run a simple test producing a beep in the speaker. With the first problem solved I could experiment with copying code from the example to get any output. After including PDM2PCM Middleware my project has the necessary include files to at least see the types used in the example. The problem is I can't build the project because of the missing functions I described.

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

Hello @Adam �?yskawa​,

Add .a file:

under Project > Properties > C/C++ Build > Settings > Tool Settings > MCU GCC Linker > Libraries add the .a library name and the path to that file. This shall make the linker happy. Note that you don't enter the "lib" prefix and the extension .a, e.g. when the filename is libmylib.a, enter mylib

Besides, under MCU GCC Compiler > Include paths add the path to the header files to make the compiler happy.

You may keep copies of the .a and .h files within the project folder tree or "out-of-tree" in a separate folder as you prefer.

Note that .a files may exist for different MCU/CPU architectures and ABIs like floating point. Make sure that you get the correct library linked in.

Foued

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

1 REPLY 1
Foued_KH
ST Employee

Hello @Adam �?yskawa​,

Add .a file:

under Project > Properties > C/C++ Build > Settings > Tool Settings > MCU GCC Linker > Libraries add the .a library name and the path to that file. This shall make the linker happy. Note that you don't enter the "lib" prefix and the extension .a, e.g. when the filename is libmylib.a, enter mylib

Besides, under MCU GCC Compiler > Include paths add the path to the header files to make the compiler happy.

You may keep copies of the .a and .h files within the project folder tree or "out-of-tree" in a separate folder as you prefer.

Note that .a files may exist for different MCU/CPU architectures and ABIs like floating point. Make sure that you get the correct library linked in.

Foued

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.