cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault error happened when executed PDM_filter function

Nagarajan
Associate III

I am trying to convert microphone PDM signal into PCM signal and i used external PDM2PCM library files (which is used for STM32L4 cortex-M4) for that, i am able to bulid it for STM32H5 controller. When i execute the blelow PDM_filter_init function i am getting the hard fault error. Could you please help me to solve this issue.

 

void MX_PDM2PCM_Init(void)
{
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */

/**
*/
PDM1_filter_handler.bit_order = PDM_FILTER_BIT_ORDER_MSB;
PDM1_filter_handler.endianness = PDM_FILTER_ENDIANNESS_BE;
PDM1_filter_handler.high_pass_tap = 2104533974;
PDM1_filter_handler.in_ptr_channels = 1;
PDM1_filter_handler.out_ptr_channels = 1;
PDM_Filter_Init(&PDM1_filter_handler); - Hard fault error occurred on this line

PDM1_filter_config.decimation_factor = PDM_FILTER_DEC_FACTOR_64;
PDM1_filter_config.output_samples_number = 125;
PDM1_filter_config.mic_gain = 0;
PDM_Filter_setConfig(&PDM1_filter_handler, &PDM1_filter_config);

/* USER CODE BEGIN 3 */
/* USER CODE END 3 */

}

6 REPLIES 6
STOne-32
ST Employee

Dear @Nagarajan ,

can you please have a screenshot on the Hardfault location and trace/log of the stack when at Hardfault while(1) . This is to check which instruction caused that .

hypothesis:

1) using a library not for Cortex-M33 / M4 should work also , but to check secure / non secure parts 

2) Initialization is missing some hardware configuration 

3) used library for PDM not ready for H5 series 

 

Let us know ,

STOne-32

Would be helpful to see the disassembly or a proper dump of the failure..

If it's the call, then perhaps vpush on the function side, and the FPU not enabled?

Have your system output actionable information

https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I enabled the CRC feature as i was told it is a part of the procedure for PDM to PCM conversion. After executing the CRC_Lock() function it is going to hard fault error. I didn't enable the FPU.

 

Nagarajan_0-1722240518277.png

 

If i disable the CRC feature also i am getting that same hard fault error. Could you please guild me how to use KeilHardFault.c file to debug the issue? 

I am not able to proceed further, would it be possible to port STM32L PCM library to STM32H5 controller or not? or can i try some other STM32 PCM library to make it work?

I changed controller for testing purpose. We are using STM32F4 - nucleo board, infineon digital microphone (IM73D122V01) and internal PDM2PCM libraryfor conversion. In I2S protocol we used input clock frequency 3.072 MHz and sampling rate 48KHz to read the data from microphone, we are getting PDM output and giving input as PDM2PCM filter but we are not getting expected audio sample output in PCM buffer. We are always getting 1 or 2 negative values and remaining full of zeros in PCM buffer. Could you please help me to solve this issue or is there any way to directly verify the PDM output?