LPC1788 MCI systematic CRC error on block write

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by agardiol on Tue Aug 28 01:44:15 MST 2012

During the migration of a project from LPC2478 to LPC1788 I get a near systematic issue when trying to write to an SD card.
After each write block attempt I get an DATA CRC error in MCI status reg. I also was able to check that data are really not written on the card.
The exception is when almost all byte are 0xFF. In that case, data are written and no CRC error occurs.

I tried to lower MCLK, PCLK and SD clock frequency (down to 2MHz) but it does not change anything.
I tried several SD card too.
I checked all errata sheet from NXP and did not find anything.

With an identical board with an LPC2478, I never get this issue. Has anyone already encountered a similar issue ?

I use a Keil RL-ARM library.

Here is the source code of the driver (MCI commands 25 send separately by the library before calling this function) :

/*--------------------------- WriteBlock -------------------------------------*/

static BOOL WriteBlock (U32 block, U8 *buf, U32 cnt) {
  /* Write a cnt number of 512 byte blocks to Flash Card. */
  U32 i,j;

  for (j = 0; j < cnt; buf += 512, j++) {
/* Set MCI Transfer registers. */

    /* Start DMA Memory to Peripheral transfer. */
    DmaStart (DMA_WRITE, buf);
    LPC_MCI->DATACTRL = 0x99;

    for (i = DMA_TOUT; i; i--) {
      if (LPC_GPDMA->RawIntTCStat & 0x01) {
        /* Data transfer finished. */

    if (i == 0) {
      /* DMA Data Transfer timeout. */
      return (__FALSE);

    if (cnt == 1) {

    /* Wait until Data Block sent to Card. */
        /* Error while Data Block sending occured. */
return (__FALSE); <------------------------------------------------------ systematic error with LPC_MCI->STATUS = 0x02

    /* Wait 2 SD clocks */
    for (i = WAIT_2SD_CLK(__CPUCLK); i; i--);
  return (__TRUE);

Thanks by advance and best regards.
Antoine Gardiol