Content originally posted in LPCWare by wella-tabor on Fri May 24 04:16:20 MST 2013Hello,
Your source code did not pass throught the test (see below). Do not worry, either my driver did not pass with the 4-wire interface. It seems that card or PL180 (arm prime cell used in nxp) is buggy. The lpcopen uses checking of state before sending the STOP command, maybe there is the catch.
<hr />my modification to your source code was to set max_transfer_sectors = 8 and speed to 1.000.000 Hz
Test code:
<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_inithardware();
mmc_init_card();
// 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_writemultiplesector(buffer,sector_addresses, sector_bursts[j]);
if(error != 0)
{
__asm("BKPT 1\n");
}
//clear buffer.
memset(buffer, 0, BLOCK_SIZE * sector_bursts[j]);
//read block
error =mmc_readmultiplesector(buffer,sector_addresses, sector_bursts[j]);
if(error != 0)
{
__asm("BKPT 1\n");
break;
}
// Here comes checking
for (unsigned k = 0; k < BLOCK_SIZE * sector_bursts[j]; ++k)
{
if (buffer[k] != (i+1)*(j+1))
{
__asm("BKPT 1\n");
break;
}
}
}
}
while(1)
{
}
return 1;
}
</code>