PDM_PCM with DMA data transfer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lking
Moderator
Moderator
Moderator
50 sign-ins 10 likes received 10 replies posted
I am using the digital microphones on CY8CPROTO-062-4343W and having a problem when using the DMA to transfer data from the PDM to memory. I have the following code to setup the PDM

/* Initialize the PDM/PCM block */
active_rx_buffer = audio_frame0;
full_rx_buffer = audio_frame1;
cyhal_pdm_pcm_init(&pdm_pcm, PDM_DATA, PDM_CLK, &audio_clock, &pdm_pcm_cfg);
cyhal_pdm_pcm_register_callback(&pdm_pcm, pdm_pcm_isr_handler, NULL);
// cyhal_pdm_pcm_set_async_mode(&pdm_pcm, CYHAL_ASYNC_DMA, CYHAL_DMA_PRIORITY_DEFAULT); // turn on DMA, currently broken
cyhal_pdm_pcm_enable_event(&pdm_pcm, CYHAL_PDM_PCM_ASYNC_COMPLETE, CYHAL_ISR_PRIORITY_DEFAULT, true);
cyhal_pdm_pcm_start(&pdm_pcm);
cyhal_pdm_pcm_read_async(&pdm_pcm, active_rx_buffer, FRAME_SIZE); // trigger the first packet

The remainder of the code is similar to the code in Github posted here: https://github.com/infineon/mtb-example-psoc6-pdm-pcm two days ago, and snippet 2 posted here: https://infineon.github.io/mtb-hal-cat1/html/group__group__hal__pdmpcm.html.
When the cyhal_pdm_pcm_set_async_mode() is commented out the application works as expected.
When I turn on the DMA I get 4x more callbacks per second and all of the data in the second buffer is corrupt.
Is there a problem with the HAL library routines?

 

0 Likes
1 Solution
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Hello. I was able to reproduce this problem. I will file an internal ticket to address this issue.

In the meanwhile, we recommend to use the interrupt based ASYNC reads. Actually there is not much gain using DMA here, because of the way the HAL implements the DMA based transfers. It uses software triggers to do so. 

View solution in original post

0 Likes
1 Reply
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Hello. I was able to reproduce this problem. I will file an internal ticket to address this issue.

In the meanwhile, we recommend to use the interrupt based ASYNC reads. Actually there is not much gain using DMA here, because of the way the HAL implements the DMA based transfers. It uses software triggers to do so. 

0 Likes