How to make edma read 16-bits MSB as pdm data width is 32-bits

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to make edma read 16-bits MSB as pdm data width is 32-bits

1,338 Views
yalin
Contributor II

Dear support,

As I use RT1170, the PDM data width is 32-bits, but I just need a 16-bits audio data. And I'd like to use the pdm_sai_edma SDK for faster data transfer, how can I make edma read just 16-bits MSB of pdm data and then send it to s_buffer? (I can get 16-bits audio data by taking 16-bits MSB when 32-bits data get to s_buffer, but I perfer to do it as edma reading and then I just need to transfer half the amount of data)

Thanks.

0 Kudos
Reply
3 Replies

1,320 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

I review the code about the s_buffer and I suggest changing the size of the buffer in macro [BUFFER_SIZE] to 2 bytes.

if (s_bufferValidBlock > 0)
{
    pdmXfer.data         = (uint8_t *)((uint32_t)s_buffer + s_readIndex * BUFFER_SIZE);
    pdmXfer.dataSize     = BUFFER_SIZE;
    pdmXfer.linkTransfer = NULL;
    if (kStatus_Success == PDM_TransferReceiveEDMA(DEMO_PDM, &s_pdmRxHandle, &pdmXfer))
    {
        s_readIndex++;
    }
    if (s_readIndex == BUFFER_NUMBER)
    {
        s_readIndex = 0U;
    }
}

 I hope this works for your application if you need more information please let me know.

Best regards,
Pavel

0 Kudos
Reply

1,314 Views
yalin
Contributor II

Hello Pavel_Hernandez,

Do you mean to modify code like the following in pdm_sai_edma.c?

#define BUFFER_SIZE (16)

When I do it, the demo will be blocked, and the log is like the following.

PDM SAI Edma example started!
ASSERT ERROR " fsl_edma.c:1013 : (transferBytes % bytesEachRequest) == 0U

0 Kudos
Reply

1,307 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

The number indicated in the macro BUFFER_SIZE is in bytes, 2 bytes for 16 bits, but recently the IDE [11.6] and the SDK [2.12] were updated, could you try to use the new version, I saw this change for this.

Spoiler
xfer.dataSize = BUFFER_SIZE * 2U;

Best regards,
Pavel

0 Kudos
Reply