Need HELP with SAI EDMA (SDK2.5)

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

Need HELP with SAI EDMA (SDK2.5)

607 Views
oleglavrukhin
Contributor IV

Hello, community!

I am trying to implement playing MP3 data through the SAI module of FRDM-K82 using SDK2.5.
The MP3 decoder produces 2304 samples of int16 which must be sent via SAI to an external DAC.

Using SAI in Interrupt mode works fine.
From example of SDK_2.5.0_TWR_K64 I do
SAI_TransferTxCreateHandle (DEMO_SAI, & txHandleIRQ, callback, NULL)
and
TransferTxSetFormat (DEMO_SAI, & txHandleIRQ, & format, mclkSourceClockHz, format.masterClockHz);


In the callback function, I set the sign of the end of the transfer:

volatile bool isFinished = false;

static void callback (I2S_Type * base, sai_handle_t * handle, status_t status, void * userData)
{
    isFinished = true;
}

and transfer the data that must be sent to SAI

void play_IRQ_simply (uint8_t * wav_data, uint32_t lenght)
{
    xfer.data = wav_data;
    xfer.dataSize = lenght;
    SAI_TransferSendNonBlocking (DEMO_SAI, & txHandleIRQ, & xfer);
    while (isFinished! = true) {};
    isFinished = false;
}

everything works great, but I would like to use DMA mode so as not to take up processor time.

If I try to repeat the functions described above, but for DMA mode, i.e. using SAI_TransferSendEDMA () instead of SAI_TransferSendNonBlocking () (of course after initiating the SAI module in DMA mode), I get a distorted sound and its speed is Incorrect.

I understand that I need to wait for end of the data transfer in the SAI module, but I can’t find how to do it.

The description of function SAI_TransferSendEDMA():
<"This interface returns immediately after the transfer initiates. Call SAI_GetTransferStatus to poll the

transfer status and check whether the SAI transfer is finished">

however, the SAI_GetTransferStatus function is MISSING in the SDK!

I tried using the SAI_TransferGetSendCountEDMA () function in a callback, but did not get what I wanted result (the sound is still distorted).

In the Kinetis SDK 1.3. there was a separate files <fsl_souncard>, thanks to him I got an excellent result,
but in new versions it is absent.

I ask to share wisdom, how can I:
1) get the end of the transfer module SAI EDMA
2) regularly transfer data to the SAI EDMA module
3) what the SAI EDMA callback function should look like.


with respect
Oleg

Tags (1)
0 Kudos
1 Reply

502 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello oleglavrukhin‌,

A pretty similar implementation is found in the SDK from the FRDM-K66 and is called sai_edma_transfer (link for download here), I will suggest to check it.

I hope this helps you.

Best Regards,

Alexis Andalon

0 Kudos