imx rt600 Adapting DMIC to I2S Recording Code example to Save Data to an SD Card

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

imx rt600 Adapting DMIC to I2S Recording Code example to Save Data to an SD Card

844 次查看
fafner
Contributor I

Hi,

I am working on a project using the MIMXRT685-AUD evaluation kit and need to modify the example code to save recorded audio data to an SD card instead of playing it back via I2S. The current setup includes DMIC channels for audio capture, DMA for data transfer, and FreeRTOS for task management.

Current RecordPlayBackTask Function (from dmic i2s hwvad example):

 

static void RecordPlayBackTask(void *pvParameters)
{
    uint32_t startTicks = 0U;
    i2s_transfer_t i2sTxTransfer;
    s_recordPlaybackSemaphore = xSemaphoreCreateBinary();

    xSemaphoreGive(s_recordPlaybackSemaphore);

    while (1)
    {
        xSemaphoreTake(s_recordPlaybackSemaphore, portMAX_DELAY);

        s_RecordEmptyBlock = PLAYBACK_BUFFER_NUM;
        s_isDMICTriggerred = false;
        s_m2mBufferReady   = false;
        s_dmicBufferIndex  = 0U;
        s_m2mBufferIndex   = 0U;
        DEMO_PreparingRecordDMIC();
        DEMO_DMAMemcpyChannelConfigurations();

        startTicks = xTaskGetTickCount();

        while (1)
        {
            if (s_RecordEmptyBlock < PLAYBACK_BUFFER_NUM)
            {
                i2sTxTransfer.data     = s_processedAudio + (s_m2mBufferIndex == 0U ? 1U : 0U) * PLAYBACK_BUFFER_SIZE;
                i2sTxTransfer.dataSize = PLAYBACK_BUFFER_SIZE;
                I2S_TxTransferSendDMA(DEMO_I2S_TX, &s_i2sTxHandle, i2sTxTransfer);
            }

            if ((s_isDMICTriggerred) && (s_m2mBufferReady))
            {
                s_isDMICTriggerred = false;
                s_m2mBufferReady   = false;
                DMA_StartTransfer(&s_memcpyDmaHandle0);
            }

            if (xTaskGetTickCount() - startTicks > DEMO_RECORD_PLAYBACK_TIME_MS)
            {
                DEMO_AbortRecordPlayback();
                break;
            }
        }

        xSemaphoreGive(s_menuTasksSemaphore);
    }
}

 

 

Objective:

I need to modify this task to save the audio data to an SD card instead of sending it to I2S for playback.

Questions:

  1. Can the recording to SD file be managed within this task?
  2. If so, do I have to point the DMA stream to the SD card or buffer it on the CPU and use f_write?
  3. Do I need to do any data compression of the mic signal?

Any guidance, sample code, or references would be greatly appreciated!

Thank you in advance for your help.

0 项奖励
回复
1 回复

806 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @fafner,

1. Yes, it can be done. Please look into the SD card example we provide on the SDK like "sdcard_fatfs" or "sdcard_freertos" in order to have a reference on how to implement this.

2. To access the SD card you would need to use f_write, yes.

3. Optional. It is not required but could be a good practice depending on the amount of data you expect to write to the SD card.

BR,
Edwin.

0 项奖励
回复