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

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

formatting link

Reply to
bobo
Loading thread data ...

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.

Reply to
larwe

50KB/s)

S=

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

formatting link

Reply to
bobo

50KB/s)

S=

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

formatting link

Reply to
bobo

,

is

f

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

Reply to
larwe

(about

LPC2478=

th=

i=

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

formatting link

Reply to
bobo

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/
 Click to see the full signature
Reply to
Boudewijn Dijkstra

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.