How to get SDK versions of DMIC examples going

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

How to get SDK versions of DMIC examples going

929 Views
jameswhitney
Contributor II

Hello, I am migrating from LPCOpen DMIC examples to MCUXpresso SDK DMIC examples. I am using the LPCXpresso54114 Audio and Voice Kit with the MAO shield. Previously, I built and ran the LPCOpen 'periph_i2s_dmic' example.  I take the CODEC output from the shield into an amplifier/headphones. This example worked just fine 'out-of-the-box'.

I am now trying the various SDK DMIC examples. There are two projects which are supposed to send data to the CODEC in a similar way: 1 - The 'DMIC_I2S_CODEC' project and 2 - the 'DMIC_I2S_DMA' project. So far I have been unable to get any audio output from either of these projects.

Also, in both projects there are two sections of code which are commented out; should these be uncommented ? Both sections ?

Thanks,

Jim

Tags (1)
0 Kudos
4 Replies

783 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, James,

Sorry for the delay.

From our discussion, I see that you want to read the voice data from DMIC and save the data in a File in SD card.

First of all, the LPC54114 has not the SD/MMC interface, in other words, you can connect a SD card connector on the LPC54114.

I suggest you use the other LPC family for example LPC54618, it has SD/MMC module, you can connect a SD card connector to the LPC54618 SD/MMC interface.

We have developed the fatfs middleware code, and the fatfs example, you can use mount/create to establish a file in FAT format, use open/write...function to write the data to a file.

Regarding the dmic code, because you do not use DAM, I2S, so you can truncate the dmic code, for example configure the dmic clock, dmic module, in the ISR of dmic, you can read the FIFO of DMIC and write the data to a large buffer, when the buffer is full, then stop reading data, then write the data in buffer to a File.

I post the screenshot of fatfs example.

Hope it can help you

BR

XiangJun Rong

pastedImage_1.png

0 Kudos

783 Views
jameswhitney
Contributor II

Hello, Xiangjun,

Thank you for the quick reply and suggestions. I have a few more questions/comments.

  • Yes, the *COMPLETE* objective of the project is to capture voice data from the DMIC and save it to SD card
  • No worries for the SD card/FatFS - awhile back NXP/Mr. Kerry Zhou helped me port a Luxcel board FatFs project. I then came up with a 'formula' for porting FatFS to other projects. I have already ported SD card/FatFS to the DMIC_I2S_DMA project. I was trying to find the best place to capture the data. However, I like your idea of capturing the data directly from the FIFO.

Normally, BEFORE I contact the Community, or, Technical/Application Engineering I like to work the problem myself to see where I might actually get stuck. However, since we are in contact I have a few questions:

  1. The reason I contacted NXP/you was to see which template might be best for my project: 'DMIC_I2S_DMA', or, 'DMIC_I2S_CODEC' (actually, they both use the CODEC). Even though we have the DMA program running, can you please comment on your opinion as to which one will be better to convert ?
  2. In the DMA program version, at what point in the program does the DMIC data sampling actually begin ?
  3. You mention an ISR for the DMIC - does this exist already, or, is it something I need to write ?
  4. What/where is the best place to gain access to the FIFO data ?

Again, normally, I would attack these things before contacting you, but as we are already discussing them I would appreciate your opinion. If you have any other tips to get me going they will be appreciated.

Best regards,

Jim

0 Kudos

783 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, James,

I have checked both the 'DMIC_I2S_DMA', or, 'DMIC_I2S_CODEC' , the second example puts the DMIC sample data to I2S transmitter FIFO directly, you can not use it or you need to change it. I suggest you use the 'DMIC_I2S_DMA' example.

For the 'DMIC_I2S_DMA' example, the example uses DMA to transfer DMIC data FIFO to a large buffer, when the buffer is full, the DMIC_UserCallback() is called. In the DMIC_UserCallback() function, a flag g_Transfer_Done is set.

In the main, you need to poll the flag, when it is set, you know the buffer is full, so you can write the buffer to File.

/* DMIC user callback */
void DMIC_UserCallback(DMIC_Type *base, dmic_dma_handle_t *handle, status_t status, void *userData)
{
    userData = userData;
    if (status == kStatus_DMIC_Idle)
    {
        g_Transfer_Done = true;
    }
}

uint16_t g_rxBuffer_PING[BUFFER_LENGTH] = {0};

uint16_t g_rxBuffer_PONG[BUFFER_LENGTH] = {0};

bool PING_flag;

while(1)   

{

/* Wait for DMA transfer finish */
    while (g_Transfer_Done == false) {} //waiting for the buffer is full
    if(PING_flag)

       {

           receiveXfer.dataSize = 2 * BUFFER_LENGTH;
           receiveXfer.data = g_rxBuffer_PONG; //use Ping-Pong buffer if you like
            DMIC_TransferReceiveDMA(DMIC0, &g_dmicDmaHandle, &receiveXfer, APP_DMIC_CHANNEL);

          PING_flag=false;
            //write data from g_rxBuffer_Ping to File
        }

     else

       {

          receiveXfer.dataSize = 2 * BUFFER_LENGTH;
           receiveXfer.data = g_rxBuffer_PING; //use Ping-Pong buffer if you like
            DMIC_TransferReceiveDMA(DMIC0, &g_dmicDmaHandle, &receiveXfer, APP_DMIC_CHANNEL);

           PING_flag=true;
            //write data from g_rxBuffer_PONG to File

        }

}

Hope it can help you

BR

Xiangjun Rong

0 Kudos

783 Views
jameswhitney
Contributor II

Hello, XiangJun,

Thanks, so much.

Will give a try to all that you have suggested.

Best regards,

Jim

0 Kudos