DISK READ FAILURE

Hi,

I am working on a project where MP3 files from SD card are fetched and played when play button is pressed.

I am configuring buttons as interrupt mode and when the button is pressed the play flag is set in the interrupt handler.

Also, a timer is running for every 1 second and in the timer handler the play flag, pause flag etc, are monitored and play_mp3() function is called inside the handler.

The mp3 file in sd card is opened by f_open() function to read the file. when it is trying to read disk the busy flag is not setting to false

DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count)
{
ASSERT(m_drives);

if ((drv >= m_drives_count) || (!count))
{
return RES_PARERR; // Invalid parameter(s).
}

if ((m_drives[drv].config.p_block_device == NULL)
|| (m_drives[drv].state & STA_NOINIT))
{
return RES_NOTRDY; // Disk not initialized.
}

const nrf_block_req_t req = {
.p_buff = buff,
.blk_id = sector,
.blk_count = count
};

m_drives[drv].busy = true;
ret_code_t err_code = nrf_blk_dev_read_req(m_drives[drv].config.p_block_device, &req);

if (err_code == NRF_SUCCESS)
{
while (m_drives[drv].busy)
{
m_drives[drv].config.wait_func();
}

if (m_drives[drv].last_result == NRF_BLOCK_DEV_RESULT_SUCCESS)
{
return RES_OK;
}
}
return RES_ERROR;
}

The function then sets the busy flag of the drive to true, indicating that the read operation is in progress. It then calls nrf_blk_dev_read_req(), a function provided by the Nordic SDK, to initiate the read operation.

If the read request is successfully initiated, the function enters a while loop that checks the busy flag of the drive. The wait_func() function, provided by the FatFs library, is called to wait for the read operation to complete.

But the busy flag is not setting false.

Thanks 

Parents Reply Children
No Data
Related