AnsweredAssumed Answered

k70 with MQX 4.1 . SD card read issue (For bigger file Size > 1MB)

Question asked by soham dandapat on May 23, 2019
Latest reply on May 30, 2019 by soham dandapat

I am trying to read data from SD card (Sandisk 4 GB) using eSDHC driver . I am not able to read complete file if file size is more than 1 MB..

 

I tried below:

1) decrease the speed in the sdhc conf structure (mqx/bsp/<board>/init_sdhc0.c file).

const ESDHC_INIT_STRUCT _bsp_esdhc0_init = {

    0,                          /* ESDHC device number */

    25000000,                   /* ESDHC baudrate      */  >>>>>>>>>>>>>>> change this to the 4000000 <<<<<<<<<<

    BSP_SYSTEM_CLOCK            /* ESDHC clock source  */

};

Also change to         baudrate = 10000000, baudrate = 1000000, baudrate = 100000, baudrate = 10000, baudrate = 1000, baudrate = 100 .

   if (ESDHC_OK != ioctl (sdcard_ptr->COM_DEVICE, IO_IOCTL_ESDHC_GET_BAUDRATE_MAX, &baudrate))

    {

        return FALSE;

    }

 

 

    //baudrate = 10000000; <-- Here i did the change

    if (param > baudrate)

    {

        param = baudrate;

    }

    if (ESDHC_OK != ioctl (sdcard_ptr->COM_DEVICE, IO_IOCTL_ESDHC_SET_BAUDRATE, &param))

    {

        return FALSE;

    }

 

2) disable and enable interrupt

In esdhc_read() beginning at around line 1554:

  1. #if ESDHC_IS_HANDLING_CACHE  
  2.     _int_disable();  
  3.   
  4.   
  5.     if (head_len)  
  6.     {  
  7.       _DCACHE_INVALIDATE_LINE(head);  
  8.       _mem_copy(head, data_ptr, head_len);  
  9.     }  
  10.   
  11.   
  12.     if (body_len)  
  13.     {  
  14.         _DCACHE_INVALIDATE_MBYTES(body, body_len);  
  15.     }  
  16.   
  17.   
  18.     if  (tail_len)  
  19.     {  
  20.       _DCACHE_INVALIDATE_LINE(tail);  
  21.       _mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);  
  22.     }  
  23.   
  24.   
  25.     _int_enable();  
  26. #endif  
  27.     {  
  28.       _DCACHE_INVALIDATE_LINE(tail);  
  29.       _mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);  
  30.     }  

 

In esdhc_write() beginning at around line 1692:

  1.     _int_disable();  
  2.      
  3.     /* Flush caches */  
  4.     if (head_len)  
  5.     {  
  6.         _mem_copy(data_ptr, head, head_len);  
  7.         _DCACHE_FLUSH_LINE(head);  
  8.     }  
  9.   
  10.   
  11.     if (body_len)  
  12.     {  
  13.         _DCACHE_FLUSH_MBYTES(body, body_len);  
  14.     }  
  15.   
  16.   
  17.     if (tail_len)  
  18.     {  
  19.         _mem_copy(((uint8_t*)data_ptr) + head_len + body_len, tail, tail_len);  
  20.         _DCACHE_FLUSH_LINE(tail);  
  21.     }  
  22.   
  23.       _int_enable();  

 

 

But still no luck ..

 

 

Can anyone please help me where I am doing wrong / or any other solutions ??

Outcomes