Conversion to PDM to PCM using FIR and decimation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-12-27 8:18 AM
I am trying to decimate a PDM signal in order to obtain a PCM signal. Is this code correct?
void LowPassFilterWithDecimation(uint8_t *pdm1, uint8_t *pdm2, int32_t *pcm1, int32_t *pcm2, int pdm_buffer_size, int decimation_factor){
char str[100];
// initialize buffers
for(uint16_t i = 0; i < pdm_buffer_size/decimation_factor; i++){
// initialize raw microphones buffers
pcm1[i] = 0;
pcm2[i] = 0;
}
for(uint16_t i = 0; i < pdm_buffer_size; i += decimation_factor){
for(uint8_t j = 0; j < NUM_TAPS; j++){
pcm1[i/decimation_factor] += pdm1[i + j] * fir_coeff[j];
pcm2[i/decimation_factor] += pdm2[i + j] * fir_coeff[j];
// trasmit via uart
sprintf(str, "%ld,%ld\r\n", pcm1[i/decimation_factor], pcm2[i/decimation_factor]);
HAL_UART_Transmit(&huart2, (uint8_t*)str, strlen(str), 10);
}
}
}
Labels:
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-01-04 8:43 AM
Hi @ATeli.1 ,
Please provide which STM32 your are using/targeting ?
I'm not an audio expert, but I think using DFSDM (or MDF) present on some STM32 MCU or MPU will make such conversion much simpler and faster as DFSDM embed digital filters in HW.
Regards.
In order 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.
