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

SD-Card writing blocks ADC

Hello,

I'm trying to write my ADC samples over spi on a sd card (Using SAADC like in the sdk 12 example with PPI and using fatfs like in the example in the sdk).

I open the file I want to write in only once in the beginning and close it in the end, not every time when I write in the file.

Everything works, but because I use timestamps after every sample I can see that everytime I call the f_write function, my ADC is blocked for a few miliseconds. The time where it's blocked depends on the amount of data I send.

I know that the disk_write function waits for the write done event (busy flag):

ret_code_t err_code = nrf_blk_dev_write_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;

So I think this while loop is where my code blocks. I tried to delete the waiting part, going on with my sampling and checking before writing again if the device is still busy.

No error occurs, but when I read out my card on Pc the file is empty.

Is it somehow possible to go on sampling the ADC while writing on the SD card?

Regards Lea

Parents
  • Hi Ankush, is the Sending the problem or writing on SD Card while sampling the ADC? I had the same problem, my code got stuck when I tried to write my samples on SD Card. So I now set the interrupt priority of my adc to 6 and the one of my sd card to 3. Before they had the same priority or adc had a higher priority. So have you tried writing your samples on SD card without sending them and did this work?

  • Hi,

    Some data is being written on SD card card but after some time code gets restarted. Is it the issue of clock frequency of SPI or sampling frequency of SAADC. SPI0_DEFAULT_FREQUENCY and APP_SDCARD_FREQ_INIT are set to 4 MHz. and Sampling frequency of SAADC is 1000sps. I am sampling SAADC using PPI.

Reply Children
No Data
Related