EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

speed of writing file is fixed when changing the CLK of SD/MMC

Started by bobo February 5, 2010
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
On Feb 5, 8:33=A0pm, "bobo" <beyondsa...@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.
>On Feb 5, 8:33=A0pm, "bobo" <beyondsa...@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
>On Feb 5, 8:33=A0pm, "bobo" <beyondsa...@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
On Feb 7, 11:20=A0am, "bobo" <beyondsakai@n_o_s_p_a_m.126.com> wrote:
> >On Feb 5, 8:33=3DA0pm, "bobo" <beyondsa...@126.com> wrote: > >> Hello All, > >> =3DA0 =3DA0 I met a strange problem : > >> =3DA0 =3DA0 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=3D > >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 th=
is
> operation, the controller int the SD/MMC card will do this automaticly, i=
f The card does it automatically, but it STILL TAKES FINITE TIME.
>On Feb 7, 11:20=A0am, "bobo" <beyondsakai@n_o_s_p_a_m.126.com> wrote: >> >On Feb 5, 8:33=3DA0pm, "bobo" <beyondsa...@126.com> wrote: >> >> Hello All, >> >> =3DA0 =3DA0 I met a strange problem : >> >> =3DA0 =3DA0 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=3D >> >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
th=
>is >> operation, the controller int the SD/MMC card will do this automaticly,
i=
>f > >The card does it automatically, but it STILL TAKES FINITE TIME. >
Hi, it's still slowly, I find that the erase a page also cost much time as write single page, and i tried to use sdmmc_write_pages() (for multiple page write) to write 1 page, it became fast, the speed up to 250~500KB/s, but it not stable enough, i write a test case to for it (just write page one by one and read ,compare, continuously) , after 300~500 times write, cmd12 timeout error occurs..., if i use sdmmc_write_pages() to write multiple pages, the timeout error occur more quickly... "The card does it automatically, but it STILL TAKES FINITE TIME.", don't you think the time is too long ? as i know, SD/MMC are similar to NAND, and the erase operation is the mostly cost time, even though, it cost only serveral millisecond. --------------------------------------- Posted through http://www.EmbeddedRelated.com
Op Sun, 07 Feb 2010 22:52:12 +0100 schreef bobo  
<beyondsakai@n_o_s_p_a_m.126.com>:
>> On Feb 7, 11:20=A0am, "bobo" <beyondsakai@n_o_s_p_a_m.126.com> wrote: >>> >On Feb 5, 8:33=3DA0pm, "bobo" <beyondsa...@126.com> wrote: > > "The card does it automatically, but it STILL TAKES FINITE TIME.", don't > you think the time is too long ?
It depends. For how much money is that card being sold? I expect cheaper cards to perform worse on average. -- Gemaakt met Opera's revolutionaire e-mailprogramma: http://www.opera.com/mail/ (remove the obvious prefix to reply by mail)

The 2024 Embedded Online Conference