From: bobo on
Hello All,
I met a strange problem :
the speed of writing file is fixed to a same value (about 50KB/s)
whatever the SD/MMC CLK (from 600KHz to 12MHz), my platform is LPC2478, SD
card is 2GB,
filesystem is FatFs; I have tried 600KHz, 1MHz, 2MHz, 3MHz, 6MHz, 12MHz,
but the Write speed seams fixed to 50KB/s, and i used the scope to observe
the CLK CMD and DATA[0:3] pins, the CLK frequency is all right, the key
problem seams that the SD card is always busy(DATA0 is low), and the CMD
line always active(because before send data to the card, i'll check the
card's status until the card state is 'tran'), so it seams that the card
take a very long time to programming. but i checked the card on my laptop,
the speed is not less than 1MB/s.

anybody knows what's the problem ?

this is the realted code:

int sdmmc_write_1page(s_sdmmc *p_card, UINT32 page_id, UINT *sendbuf)
{
int ret = 0;

ASSERT((NULL != p_card) && (NULL != sendbuf));
//if (page_id > p_card->page_gross) return
SDMMC_ERR_OVER_CAPACITY;
if (hal_sdmmc_check_wp(p_card)) return
SDMMC_ERR_WRITE_PROTECT;

ret = os_sdmmc_card_take(p_card);
ASSERT_EQ(0, ret);

/* wait the card turn to 'tran' state if need */
ret += hal_sdmmc_wait_complete(p_card, BUSY_TYPE_PROG);
ASSERT_EQ(0, ret);

ret += CMD24_write_1page(p_card, page_id); /* single page read */
ASSERT_EQ(0, ret);
/* send data to card
*/
ret += hal_sdmmc_data_send(p_card, sendbuf, p_card->page_size);
ASSERT_EQ(0, ret);

//ret += hal_sdmmc_wait_complete(p_card, BUSY_TYPE_PROG);
//ASSERT_EQ(0, ret);

ret += os_sdmmc_card_release(p_card);
ASSERT_EQ(0, ret);
return ret;
}



int sdmmc_write_pages(s_sdmmc *p_card, UINT32 page_id, int nPages, UINT
*sendbuf)
{
int ret = 0;

ASSERT((NULL != p_card) && (NULL != sendbuf));
//if (page_id > p_card->page_gross) return
SDMMC_ERR_OVER_CAPACITY;
if (hal_sdmmc_check_wp(p_card)) return
SDMMC_ERR_WRITE_PROTECT;

/* wait the card turn to 'tran' state if need */
ret = os_sdmmc_card_take(p_card);
ASSERT_EQ(0, ret);

/* wait the card turn to 'tran' state if need */
ret += hal_sdmmc_wait_complete(p_card, BUSY_TYPE_PROG);
ASSERT_EQ(0, ret);

ret += CMD25_write_pages(p_card, page_id); /* multiple page write
*/
ASSERT_EQ(0, ret);
/* send date to card
*/
ret += hal_sdmmc_data_send(p_card, sendbuf, p_card->page_size*nPages);
ASSERT_EQ(0, ret);

ret += CMD12_stop_transmit(p_card); /* send the stop cmd
*/
ASSERT_EQ(0, ret);

ret += os_sdmmc_card_release(p_card);
ASSERT_EQ(0, ret);
return ret;
}





---------------------------------------
Posted through http://www.EmbeddedRelated.com
From: larwe on
On Feb 5, 8:33 pm, "bobo" <beyondsa...(a)126.com> wrote:
> Hello All,
>     I met a strange problem :
>     the speed of writing file is fixed to a same value (about 50KB/s)
> whatever the SD/MMC CLK (from 600KHz to 12MHz), my platform is LPC2478, SD

Assuming your code actually does what you think it does, this suggests
that the time spent transferring data to/from the card over the serial
interface is buried in the time the card's controller requires for
erasing/rewriting data.
From: bobo on
>On Feb 5, 8:33=A0pm, "bobo" <beyondsa...(a)126.com> wrote:
>> Hello All,
>> =A0 =A0 I met a strange problem :
>> =A0 =A0 the speed of writing file is fixed to a same value (about
50KB/s)
>> whatever the SD/MMC CLK (from 600KHz to 12MHz), my platform is LPC2478,
S=
>D
>
>Assuming your code actually does what you think it does, this suggests
>that the time spent transferring data to/from the card over the serial
>interface is buried in the time the card's controller requires for
>erasing/rewriting data.
>

Hi larwe, shall i erase pages before write it ? but the SD/MMC needn't this
operation, the controller int the SD/MMC card will do this automaticly, if
you erase the page manually, what's the difference ? can you give some
explanation of my problem ?

---------------------------------------
Posted through http://www.EmbeddedRelated.com
From: bobo on
>On Feb 5, 8:33=A0pm, "bobo" <beyondsa...(a)126.com> wrote:
>> Hello All,
>> =A0 =A0 I met a strange problem :
>> =A0 =A0 the speed of writing file is fixed to a same value (about
50KB/s)
>> whatever the SD/MMC CLK (from 600KHz to 12MHz), my platform is LPC2478,
S=
>D
>
>Assuming your code actually does what you think it does, this suggests
>that the time spent transferring data to/from the card over the serial
>interface is buried in the time the card's controller requires for
>erasing/rewriting data.
>

Hi larwe, shall i erase pages before write it ? but the SD/MMC needn't this
operation, the controller int the SD/MMC card will do this automaticly, if
you erase the page manually, what's the difference ? can you give some
explanation of my problem ?

---------------------------------------
Posted through http://www.EmbeddedRelated.com
From: larwe on
On Feb 7, 11:20 am, "bobo" <beyondsakai(a)n_o_s_p_a_m.126.com> wrote:
> >On Feb 5, 8:33=A0pm, "bobo" <beyondsa...(a)126.com> wrote:
> >> Hello All,
> >> =A0 =A0 I met a strange problem :
> >> =A0 =A0 the speed of writing file is fixed to a same value (about
> 50KB/s)
> >> whatever the SD/MMC CLK (from 600KHz to 12MHz), my platform is LPC2478,
> S=
> >D
>
> >Assuming your code actually does what you think it does, this suggests
> >that the time spent transferring data to/from the card over the serial
> >interface is buried in the time the card's controller requires for
> >erasing/rewriting data.
>
> Hi larwe, shall i erase pages before write it ? but the SD/MMC needn't this
> operation, the controller int the SD/MMC card will do this automaticly, if

The card does it automatically, but it STILL TAKES FINITE TIME.