This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using X-nucleo-IKS02A1 shield with my nrf5340 DK to record sound with Microphone

I'm working on nrf5340 DK and I wanted to use a mic for sound detection. To do so I installed the X-nucleo-IKS02A1 shield on my board because I have seen that it is compatible with Arduino R3 format. But since then it's impossible to find good software resources to make things work as I want... I use zephyr RTOS but the sound possibilities are very limited and have no good examples.

I tried 2 ways, based on what i have seen for other nrf boards :

  • using the DMIC driver of zephyr RTOS : I think the ports are not well defined, I get an configuration error an I don't know how to fix it. Maybe the 5340 board is not compatible ?
  • Creating a PDM input : it goes well and without any errors but I don't have anything when I print my PDM data (only zeros...), maybe I'm not using the right ports ?

Is there any working examples of this hardware configuration working for mic sound recording ? It would be very useful

Parents
  • Hello, Taenor!

    Thanks for reaching out. We don't have a good coverage of samples or material for audio/sound on the nRF series in Zephyr and our SDK unfortunately. The reason for this is that drivers for the nRF I2S peripheral were added very recently. Included with these commits is a simple I2S Echo sample that you could check out. As for the two ways you have tried:

    • From what I can see the DMIC driver in Zephyr currently only works for Intel digital microphones (and are thus not supported by the nRF series).
    • This should work fine, but there might be something that isn't configured right as you say. Could you share the project? Alternatively, you can look into the Acquire MEMS microphone data sample for the IKS02A1 shield. It's important that the commits mentioned above are present and it will not work out of the box as the nRF5340 board files aren't configured to support Arduino I2S yet. However, you can follow the steps in this blog post, which covers how you can get around missing shield labels in Zephyr and our SDK.

    Best regards,
    Carl Richard

Reply
  • Hello, Taenor!

    Thanks for reaching out. We don't have a good coverage of samples or material for audio/sound on the nRF series in Zephyr and our SDK unfortunately. The reason for this is that drivers for the nRF I2S peripheral were added very recently. Included with these commits is a simple I2S Echo sample that you could check out. As for the two ways you have tried:

    • From what I can see the DMIC driver in Zephyr currently only works for Intel digital microphones (and are thus not supported by the nRF series).
    • This should work fine, but there might be something that isn't configured right as you say. Could you share the project? Alternatively, you can look into the Acquire MEMS microphone data sample for the IKS02A1 shield. It's important that the commits mentioned above are present and it will not work out of the box as the nRF5340 board files aren't configured to support Arduino I2S yet. However, you can follow the steps in this blog post, which covers how you can get around missing shield labels in Zephyr and our SDK.

    Best regards,
    Carl Richard

Children
  • > Acquire MEMS microphone data sample for the IKS02A1 shield.

    Can it also convert data to PCM in hardware?

    Is there an example for using the PDM with nrfx drivers? I tried something like below but the controller keeps crashing.

    #define MIC_BUFFER_SIZE 1000
    int16_t buffer[MIC_BUFFER_SIZE];
    
    
    void pdmEventHdlr(nrfx_pdm_evt_t const *p_evt)
    {
            printf("PDM event: %d\n", p_evt->error);
            if (p_evt->buffer_requested) {
                    nrfx_err_t ret = nrfx_pdm_buffer_set(buffer, MIC_BUFFER_SIZE);
                    if (ret != NRFX_SUCCESS) {
                            printf("error: %d\n", ret);
                            return;
                    } else {
                            puts("Buffer set\n");
                    }
            }
    }
    
    
    void main(void)
    {
            nrfx_err_t ret;
    
    
            nrfx_pdm_config_t pdmConfig = NRFX_PDM_DEFAULT_CONFIG(40, 41);
    
    
            ret = nrfx_pdm_init(&pdmConfig, pdmEventHdlr);
            if (ret != NRFX_SUCCESS) {
                    printf("error: %d\n", ret);
                    return;
            }
    
    
            nrfx_pdm_start();
            k_msleep(10000);
    }
  • I got this to work by adding

    IRQ_DIRECT_CONNECT((IRQn_Type)NRFX_IRQ_NUMBER_GET(NRF_PDM0), 0, pdm_isr_handler, 0);

    but its requesting for buffer multiple times even though i put it in mono mode. Do i need to supply different buffers?
Related