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

nRF52 I2S Datahandler to buffer save.

hello Everyone

i Need help to Use nRF52840 DK - I2S 

Now i can play music use I2S "realtime"

it means when i was Play music front of mic and then i can hear that music to speaker.

so in this time i want to record the sound and play it after some trigger accrued

but i don't know how to save mic input data to Ram Buffer.

here is my part of code - almost same "SDK14.0 I2S Example Data_handler"

when i use that data handler code.. i can play sound real-time

//////////////////////////////////////////////////////////////////////////////////////////////////////

static void data_handler(nrf_drv_i2s_buffers_t const * p_released, uint32_t status)
{
      ASSERT(p_released);

      if (!(status & NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED))
      {
            return;
      }

      if (!p_released->p_rx_buffer)
      {
            nrf_drv_i2s_buffers_t const next_buffers =

            {
                  .p_rx_buffer = m_buffer_rx[1],
                  .p_tx_buffer = m_buffer_tx[1],
            };
            APP_ERROR_CHECK(nrf_drv_i2s_next_buffers_set(&next_buffers));

            mp_block_to_check = m_buffer_rx[1];
            mp_block_to_fill = m_buffer_tx[1];
            Count = 0;

      }
      else
      {
            mp_block_to_check = p_released->p_rx_buffer;
            APP_ERROR_CHECK(nrf_drv_i2s_next_buffers_set(p_released));
            mp_block_to_fill = (uint32_t *)p_released->p_tx_buffer;

            NRF_I2S->RXD.PTR = (uint32_t)&pcm_samples[Count];
            NRF_LOG_INFO("Rx - Index:%d, Rx - Vel:0x%08x ", Count, pcm_samples[Count]); //Count, mp_block_to_check);//Count, pcm_samples[Count]);
            NRF_I2S->TXD.PTR = (uint32_t)&pcm_samples[Count - 300];
            NRF_LOG_INFO("Tx - Index:%d, Tx - Vel:0x%08x ", Count, pcm_samples[Count]);

      }

}

//////////////////////////////////////////////////////////////////////////////////////////////////////

but i want do record and play that sound after so change some part of code...

//////////////////////////////////////////////////////////////////////////////////////////////////////

if (Count >= 300)
{
      NRF_I2S->TXD.PTR = (uint32_t)&pcm_samples[Count - 300];
      NRF_LOG_INFO("Tx - Index:%d, Tx - Vel:0x%08x ", Count, pcm_samples[Count]);
}

Count  ++;

//////////////////////////////////////////////////////////////////////////////////////////////////////

i was do like that to try to play that sound delay

but after few second i can hear only "bzzzzzzzzzzzzzzz" sound 

i don't know what is wrong...

help me to solve this problem 

thanks for read.. 

i will wait reply

Thanks again .

Parents Reply Children
No Data
Related