SD CARD AND I2S

Hi Engineers,

I am trying to play an audio file from SD card, so I have interfaced SD card module and i2s module to the nrf52840. 

I am able to read all the files available in SD card with names and sizes of each audio file.

I have also successfully initialized the i2s with LRCK 44100, Streo, etc. but I am facing problems while playing audio files.

the audio quality is not so good, the audio is too fast and also there is an extra sound of ticks and pops.

please check the below code, this is how I am doing it.

void Play_MP3(){
for (uint8_t audio_files = 0; audio_files < No_of_files ; audio_files++)
{


char* FILES = file_names[audio_files];

ff_result = f_open(&file, FILES, FA_READ);
if(ff_result != FR_OK)
{
NRF_LOG_INFO("failed to open file");
return;
}

static uint32_t Presize = 0;

for(uint32_t file_data = 0; file_data < file_size[audio_files]; file_data = file_data + BUFF_SIZE)

{

ff_result = f_read(&file, (void *)Buff, sizeof(Buff), (UINT *)&bytes_written);
if(ff_result != FR_OK)
{
NRF_LOG_RAW_INFO("%s", Buff);
}

prepare_tx_data(m_buffer_tx[0]);

nrf_drv_i2s_buffers_t const initial_buffers = {
.p_tx_buffer = m_buffer_tx[0]
};

err_code = nrf_drv_i2s_start(&initial_buffers, BUFF_SIZE, 0);
APP_ERROR_CHECK(err_code);

Presize += BUFF_SIZE;
}//end of for loop 2

(void) f_close(&file);
Presize = 0;

}//end of for loop 1
return;
}

Thanks and regards

Ajmal.

Parents Reply Children
Related