cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with pdm2pcm library in vs code

baator025
Associate

Hi,
I am struggling to make PDM2PCM library work. My projects build without issues, but when I upload them to the board , program executes until it reaches PDM_Filter_setConfig function (tested with breakpoints). After that, it goes to infinite loop caused by watchdog.
I tried to integrate this library in a project with my own drivers and it was the first time I ran into this problem. To make things simple, I created an empty project to run the configuration only. The result was unfortunately the same.

I am using 32F411EDISCOVERY kit. I tested the lib using STM32Cube F4 1.28.0 and 1.26.2 packages. I am not using HAL.
Below you can find the code I used in the simpler project (it is basically code copied and pasted from the official docs).

 

#include <stdint.h>
#define STM32F411xE
#include "stm32f4xx.h"
#include "pdm2pcm_glo.h"


int main(void)
{
    RCC->AHB1ENR |= RCC_AHB1ENR_CRCEN;
    CRC->CR = CRC_CR_RESET;

    PDM_Filter_Handler_t PDM1_filter_handler;
    PDM_Filter_Config_t PDM1_filter_config;
    /* Initialize PDM Filter structure */
    PDM1_filter_handler.bit_order = PDM_FILTER_BIT_ORDER_LSB;
    PDM1_filter_handler.endianness = PDM_FILTER_ENDIANNESS_BE;
    PDM1_filter_handler.high_pass_tap = 2122358088;
    PDM1_filter_handler.out_ptr_channels = 1;
    PDM1_filter_handler.in_ptr_channels = 1;
    PDM_Filter_Init((PDM_Filter_Handler_t *)(&PDM1_filter_handler));
    PDM1_filter_config.output_samples_number = 16;
    PDM1_filter_config.mic_gain = 24;
    PDM1_filter_config.decimation_factor = PDM_FILTER_DEC_FACTOR_64;
    PDM_Filter_setConfig((PDM_Filter_Handler_t *)&PDM1_filter_handler,
    &PDM1_filter_config);
    /* Loop forever */
	for(;;);
}

CMake parts used for including the library to build system:

# Add include paths
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
    ${include_DIRS}
    $<$<COMPILE_LANGUAGE:C>: ${include_c_DIRS}>
    $<$<COMPILE_LANGUAGE:CXX>: ${include_cxx_DIRS}>
    $<$<COMPILE_LANGUAGE:ASM>: ${include_asm_DIRS}>
    "${PROJECT_SOURCE_DIR}/Drivers/CMSIS/Include"
    "${PROJECT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Include"
    "${PROJECT_SOURCE_DIR}/Middlewares/ST/STM32_Audio/Addons/PDM/Inc"
)

# Add linked libraries
target_link_libraries(${CMAKE_PROJECT_NAME} ${link_LIBS}
"${PROJECT_SOURCE_DIR}/Middlewares/ST/STM32_Audio/Addons/PDM/Lib/libPDMFilter_CM4_GCC_wc32.a")

Rest of the CMake file is unchanged.

0 REPLIES 0