This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

External SRAM check failed

Hi All,

My customer use below code to test external EMIF SRAM read and write. If we do not add the red part code, the result will be succeed, but if we add the red part code, the test will failed. Actually it just do read-and-write test one more time, so can you please give any advices?

Thanks a lot.

(We use 512k SRAM CY7C1051DV33-10ZSXI)

#define   SRAM_TEST_DATA_0     0x0000UL
#define   SRAM_TEST_DATA_1     0xFFFFUL

int Test_Sram()
{
 INT32 re=-1;
 
 re = romSramTest2(0x60000000, 0x40000);
 if(re==1)
 {
  my_printf("Sram Test Succeed!\r\n");
 }
 else
 {
  my_printf("Sram Test Failed!re=%d\r\n",re);
 }
 return re;
}

 INT32 romSramTest2(UINT32 addr,UINT32 len)
 {
  UINT16 *pRam;
  INT32 i,cnt=0;;
  INT32 re=1;
  
   pRam=(UINT16 *)addr;

   /* write all 0*/  
  for(i=0;i<len;i++)
    {
       pRam[i]=SRAM_TEST_DATA_0;
    }
   
  /*continually read and write */
  for(i=0;i<len;i++)             
    { 
    if(pRam[i]!=SRAM_TEST_DATA_0)
     {
      re=0;
      my_printf("%d: data[%d]=0x%x\r\n",cnt,i,pRam[i]);
      return;
     }
    else
     {
      pRam[i] = SRAM_TEST_DATA_1;       
     }
     
    if(pRam[i]==SRAM_TEST_DATA_1)
     {
      pRam[i] = SRAM_TEST_DATA_0;
     }
    else
     {
      re=0;
     }


//add below part will lead to failed
    if(pRam[i]!=SRAM_TEST_DATA_0)
     {
      re=0;
     }
    else
     {
      pRam[i] = SRAM_TEST_DATA_1;  
     }


   } 
  return re;
 }