Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PDM start fail

Hi, I'm using the nRF52840 SDK15.2.0
I'd like to get data from a digital microphone via a PDM interface. The teansfer data to speaker via a I2S interface.

Here is my problem:

In the ret_code_t nrf_drv_pdm_start(void)
{
...

nrf_pdm_task_trigger(NRF_PDM_TASK_START);
NRF_LOG_INFO("PDM TASKS START\r\n");
...
}

I can't see information "PDM TASKS START"


If I use
nrf_pdm_task_trigger(NRF_PDM_TASK_STOP);
NRF_LOG_INFO("PDM TASKS STOP\r\n");
I can see information "PDM TASKS STOP"

Thank you.

Parents
  • I try to port PDM part from thingy SDK to SDK_15.2 with nRF52840.
    The process hangs (no further message) after nrf_pdm_task_trigger(NRF_PDM_TASK_START).

    Is there any idea what's wrong in this code?

    ret_code_t nrf_drv_pdm_start(void)
    {
    	  ASSERT(m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED);
        ret_code_t err_code;
    		
    	  if (m_cb.status != NRF_PDM_STATE_IDLE)
        {
            if (m_cb.status == NRF_PDM_STATE_RUNNING)
            {
                err_code = NRF_SUCCESS;
                printf("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code));
                return err_code;
            }
            err_code = NRF_ERROR_BUSY;
            printf("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code));
            return err_code;
        }
        m_cb.status = NRF_PDM_STATE_TRANSITION;
        m_cb.drv_state = NRF_DRV_STATE_POWERED_ON;
        nrf_pdm_enable();
        nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED);
    
    		nrf_pdm_task_trigger(NRF_PDM_TASK_START);
    		printf("PDM-START----\r\n");	
    
        err_code = NRF_SUCCESS;
    		printf("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code));
    		return err_code;
    }
    
    ret_code_t drv_audio_enable(void)
    {
    	
    #if CONFIG_PDM_MIC_PWR_CTRL_ENABLED
    #if CONFIG_PDM_MIC_PWR_CTRL_ACT_LOW
        nrf_gpio_pin_clear(CONFIG_IO_PDM_MIC_PWR_CTRL);
    #else // !CONFIG_PDM_MIC_PWR_CTRL_ACT_LOW
        nrf_gpio_pin_set(CONFIG_IO_PDM_MIC_PWR_CTRL);
    #endif // CONFIG_PDM_MIC_PWR_CTRL_ACT_LOW
    #endif // CONFIG_PDM_MIC_PWR_CTRL_ENABLED
    
        // Skip buffers with invalid data.
        m_skip_buffers = MAX(1, ROUNDED_DIV((CONFIG_PDM_TRANSIENT_STATE_LEN * SAMPLING_RATE),
                                            (1000 * CONFIG_AUDIO_FRAME_SIZE_SAMPLES)));
    
    	  return nrf_drv_pdm_start();
    }
    
    uint32_t drv_mic_start(void)
    {
        ret_code_t status;
    
        if(m_audio_enabled == true)
        {
            return NRF_SUCCESS;
        }
        status = drv_audio_enable();
        if (status == NRF_SUCCESS)
        {
            m_audio_enabled = true;
        }
        return status;
    }
    
    int main()
    {
    	drv_audio_init(m_audio_buffer_handler);
    	drv_mic_start();
    }
    
    

  • How do you know the program hangs at nrf_pdm_task_trigger(), and not any of the functions before? Try setting a breakpoint at nrf_pdm_task_trigger() and see if your program reaches it. Here is a guide on how to debug in SES. Usually the program stops due to asserts (like APP_ERROR_CHECK()) or hardfaults, and I guess it is one of them in your case.

    Best regards,

    Simon

  • Simon, Thanks your response. The program does not hang at nrf_pdm_task_trigger().

Reply Children
Related