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

Can't get PDM code to compile


I'm trying to add PDM into my project but can't get it to compile. When I try to call

return nrfx_pdm_init(&pdm_cfg, drv_audio_pdm_event_handler);

I get the error "main() undefined reference to `nrfx_pdm_init'"

This looks like it it is in the file nrfx_pdm.c, which is included in my project - but the code is greyed out from the line

#if NRFX_CHECK(NRFX_PDM_ENABLED)

But NRFX PDM is enabled in my sdk_config.h

// <e> NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver
//==========================================================
#ifndef NRFX_PDM_ENABLED
#define NRFX_PDM_ENABLED 1
#endif

I've run out of ideas to check - can you give me any clue?

  • NRF_DRV_PDM_DEFAULT_CONFIG() only takes two parameters, _pin_clk and _pin_din. Try:

    nrf_drv_pdm_config_t pdm_cfg = NRF_DRV_PDM_DEFAULT_CONFIG(CONFIG_IO_PDM_CLK, CONFIG_IO_PDM_DATA);

    please check the definition in nrfx_pdm.h. This will set pdm_cfg with the following parameters:

    pdm_cfg =                   \
    {                                                                     \
        .mode               = (nrf_pdm_mode_t)NRFX_PDM_CONFIG_MODE,       \
        .edge               = (nrf_pdm_edge_t)NRFX_PDM_CONFIG_EDGE,       \
        .pin_clk            = _pin_clk,                                   \
        .pin_din            = _pin_din,                                   \
        .clock_freq         = (nrf_pdm_freq_t)NRFX_PDM_CONFIG_CLOCK_FREQ, \
        .gain_l             = NRF_PDM_GAIN_DEFAULT,                       \
        .gain_r             = NRF_PDM_GAIN_DEFAULT,                       \
        .interrupt_priority = NRFX_PDM_CONFIG_IRQ_PRIORITY                \
    }

    The rest of the parameters are probably from your sdk_config.h and/or apply_old_config.h.

    Search for the definitions in your project to see where they are set and changed (apply_old_config.h).

    Since you have a project up and running, I assume you have called something like nrf_drv_pdm_init() -> nrf_drv_pdm_start(), and possibly a nrf_drv_pdm_buffer_set() in between these two (and you may or may not have used the nrfx_... function names directly, instead of the legacy names, which you can find in nrf_drv_pdm.h).

    What do these function calls return? If they all return NRF_SUCCESS (=0), do you get any events in the pdm handler?
    BR,
    Edvin
Related