Hello,
I am facing problems with my SD MMC driver(not only mine) and 4 bit configuration. Is someone willing to try the following test with his/her driver and posts results? The clock is from 1MHz to XXMhz, 4 bit configuration. You need to replace the init, read,write and error check functions of course. You should use CMD12 (STOP command) and the read/write burst should be e.g. 8.
Best Martin
<code>
static uint8_t buffer[512*32];
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define SECTOR_BURST_MAX (23)
#define BLOCK_SIZE (512)
const unsigned int sector_bursts[] = {1,2,3,7,16,17,20, SECTOR_BURST_MAX};
const unsigned int sector_addresses[] =
{ 0, 1, 23, 500, 1235, 10689, 39784 };
int main(void)
{
int error;
mmc_init(); // pseudo function, put your code here
// write
for (unsigned i = 0; i < SIZE_OF_ARRAY(sector_addresses); ++i)
{
for (unsigned j = 0; j < SIZE_OF_ARRAY(sector_bursts); ++j)
{
//fill buffer to a known number.
memset(buffer, (i+1)*(j+1), BLOCK_SIZE * sector_bursts[j]);
error =mmc_write(buffer,sector_addresses, sector_bursts[j]);
if(error != ERR_OK)
{
//do something
}
//clear buffer.
memset(buffer, 0, BLOCK_SIZE * sector_bursts[j]);
//read block
error =mmc_read(buffer,sector_addresses, sector_bursts[j]);
if(error != ERR_OK)
{
//do something
break;
}
// Here comes checking
for (unsigned k = 0; k < BLOCK_SIZE * sector_bursts[j]; ++k)
{
if (buffer[k] != (i+1)*(j+1))
{
//do something
break;
}
}
}
}
while(1)
{
}</code>