Buffers in PDM module

Hi

I'm working with a PDM mic for nRF52832 SDK v17.1 on a project and I have a questions about PDM driver working.

Whats the difference between the buffer pointer in nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length) and p_evt->buffer_released set after a buffer_request event? Do they point to the same data?

2. How do I access the data in p_evt->buffer_released? I saw this thread but it's for Thingy 52 and another one for the Smart Remote but could you tell me how to implement it in 52832? I tried this code but it only displays zero.

p_buffer_released = p_evt->buffer_released;
pdm_buf = *p_buffer_released;
printf("\n\rOut: %08X",pdm_buf);
 

Unrelated question: nrf_gpio_pin_set() will set a pin to HIGH and nrf_gpio_pin_clear() will set it to LOW. I saw a couple of examples which had it vice versa. Is my assumption right or does nrf_gpio_pin_set() set a pin to LOW?

Regards

Raj

  • Hi Raj,


    Whats the difference between the buffer pointer in nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length) and p_evt->buffer_released set after a buffer_request event? Do they point to the same data?

    Could you provide more information about the pointers buffer and p_evt->buffer_released? 


    How do I access the data in p_evt->buffer_released? I saw this thread but it's for Thingy 52 and another one for the Smart Remote but could you tell me how to implement it in 52832? I tried this code but it only displays zero.

    It might be that the code displays zero because that is the content of the buffer. You would need to check the content of the buffer and verify that it is not zero.


    Unrelated question: nrf_gpio_pin_set() will set a pin to HIGH and nrf_gpio_pin_clear() will set it to LOW. I saw a couple of examples which had it vice versa. Is my assumption right or does nrf_gpio_pin_set() set a pin to LOW?

    Could you specify the examples that you saw?

    Best regards,
    Dejan

  • Could you provide more information about the pointers buffer and p_evt->buffer_released? 

    This is what I read and I'm trying to understand how the buffer is set. It says another event is generated after a buffer_request event and calling the nrfx_pdm_buffer_set(). I'm looking to reuse the buffer after displaying it. 

    Could you specify the examples that you saw?

    You can find it here.

  • Hi,

    This example provides code part relevant to setting the buffer

    void nrfx_pdm_event_handler(nrfx_pdm_evt_t const * const p_evt)
    {
        if(p_evt->buffer_requested)
        {
            nrfx_pdm_buffer_set(pdm_buf, PDM_BUF_SIZE);
        }
        if(p_evt->buffer_released != 0)
        {
            printf("Out: %.2x %.2x\r\n", (uint16_t)pdm_buf[0], (uint16_t)pdm_buf[1]);
        }
    }


    Best regards,
    Dejan

Related