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, ¶m))
{
return FALSE;
}
2) disable and enable interrupt
In esdhc_read() beginning at around line 1554:
- #if ESDHC_IS_HANDLING_CACHE
- _int_disable();
-
-
- if (head_len)
- {
- _DCACHE_INVALIDATE_LINE(head);
- _mem_copy(head, data_ptr, head_len);
- }
-
-
- if (body_len)
- {
- _DCACHE_INVALIDATE_MBYTES(body, body_len);
- }
-
-
- if (tail_len)
- {
- _DCACHE_INVALIDATE_LINE(tail);
- _mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);
- }
-
-
- _int_enable();
- #endif
- {
- _DCACHE_INVALIDATE_LINE(tail);
- _mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);
- }
In esdhc_write() beginning at around line 1692:
- _int_disable();
-
- /* Flush caches */
- if (head_len)
- {
- _mem_copy(data_ptr, head, head_len);
- _DCACHE_FLUSH_LINE(head);
- }
-
-
- if (body_len)
- {
- _DCACHE_FLUSH_MBYTES(body, body_len);
- }
-
-
- if (tail_len)
- {
- _mem_copy(((uint8_t*)data_ptr) + head_len + body_len, tail, tail_len);
- _DCACHE_FLUSH_LINE(tail);
- }
-
- _int_enable();
But still no luck ..
Can anyone please help me where I am doing wrong / or any other solutions ??