LPC1788 MCI systematic CRC error on block write

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1788 MCI systematic CRC error on block write

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by agardiol on Tue Aug 28 01:44:15 MST 2012
Hi,

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. */
LPC_MCI->DATATMR  = DATA_WR_TOUT_VALUE;
LPC_MCI->DATALEN  = 512;

    /* 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. */
        break;
      }
    }

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

    if (cnt == 1) {
      break;
    }

    /* Wait until Data Block sent to Card. */
    while (LPC_MCI->STATUS != (MCI_DATA_END | MCI_DATA_BLK_END)) {
      if (LPC_MCI->STATUS & (MCI_DATA_CRC_FAIL | MCI_DATA_TIMEOUT)) {
        /* 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
Labels (1)
0 Kudos
3 Replies

536 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Fri Sep 07 13:59:29 MST 2012
@Morten Kristiansen: Do you have tried it?
0 Kudos

536 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lien.Nguyen on Tue Aug 28 19:22:13 MST 2012
You can use the latest MCI driver from the link http://sw.lpcware.com/?p=lpc177x_8x.git&a=summary.
There are many updates on this driver.

Best Regards,
Lien
0 Kudos

536 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by millibit on Tue Aug 28 07:55:51 MST 2012
I observe the same problem. It seems the MCI code is pretty buggy. In this thread: http://www.lpcware.com/content/forum/lpc1788-mci-problems wmues has uploaded his own work. I'm planning to try it out tomorrow. Hope it helps.

Regards, Morten Kristiansen
0 Kudos