2.8k views
in System Integration by
How can I verify that the SDRAM is working correctly?

1 Answer

0 votes
by
 
Best answer

Hello,

before an Embedded Wizard GUI application is running on a custom specific hardware, it is essential that the entire hardware including SDRAM is working properly. The SDRAM timing and refresh parameter have been set carefully according the datasheet of the memory.

In order to verify that the SDRAM of a custom specific hardware is working correctly, the following memory test is helpful. Please put the following code snippet before the initialization of the memory manager:

{
  unsigned char* ptr;
  unsigned char  data;
  unsigned long  count;

  EwPrint( "Check memory addr 0x%08X size 0x%08X\n", MEMORY_POOL_ADDR, MEMORY_POOL_SIZE );
  EwPrint( "Write test pattern to SDRAM...               " );
  ptr = (unsigned char*)( MEMORY_POOL_ADDR );
  data = 0x00;
  count = MEMORY_POOL_SIZE;
  while ( count-- )
  {
    *ptr++ = data++;
    if ( data >= 253 )
      data = 0;
  }
  EwPrint( "[OK]\n" );

  EwPrint( "Read test pattern from SDRAM...              " );
  ptr = (unsigned char*)( MEMORY_POOL_ADDR );
  data = 0x00;
  count = MEMORY_POOL_SIZE;
  while ( count-- )
  {
    if ( *ptr++ != data++ )
      EwPrint( "Error at address 0x%08X\n", ptr-1 );
    if ( data >= 253 )
      data = 0;
  }
  EwPrint( "[OK]\n" );
}

In order to ensure that the refresh is working correctly, you can repeat the read sequence after a few seconds.

I hope this helps...

Manfred.

 

by
What is the best plan of action if this fails?

I have a error a various addresses?

Thanks
by
Difficult to say...

Typically, the timing for the SDRAM is incorrect, sometimes there are conflicts in the configuration of I/O pins for other peripherals. Sometimes the hardware / layout is causing troubles...
by
In my custom harware i dont have usart for console what can i do to check the harware test.
by

You can toggle a GPIO (e.g. connected with a LED) in case that an error happend.

Please make sure to repeat the read test several times - after 10 seconds or more - without writing or reading the memory during this time. Just to be sure that the refresh operates correctly.

void TestSDRAM( void )
{
  unsigned char* ptr;
  unsigned char  data;
  unsigned long  count;
 
  unsigned char pool[ EW_MEMORY_POOL_SIZE ];
 
  EwPrint( "Check memory addr 0x%08X size 0x%08X\r\n", &pool[0], EW_MEMORY_POOL_SIZE );
  EwPrint( "Write test pattern to SDRAM...               " );
  ptr = (unsigned char*)( &pool[0] );
  data = 0x00;
  count = EW_MEMORY_POOL_SIZE;
  while ( count-- )
  {
    *ptr++ = data++;
    if ( data >= 253 )
      data = 0;
  }
  EwPrint( "[OK]\r\n" );
 
  while ( 1 )
  {
    int w;
 
    EwPrint( "Read test pattern from SDRAM...              " );
    ptr = (unsigned char*)( &pool[0] );
    data = 0x00;
    count = EW_MEMORY_POOL_SIZE;
    while ( count-- )
    {
      if ( *ptr++ != data++ )
        EwPrint( "Error at address 0x%08X\r\n", ptr-1 );
      if ( data >= 253 )
        data = 0;
    }
    EwPrint( "[OK]\r\n" );
 
    EwPrint( "Waiting" );
    for ( w = 0; w < 10; w++ )
    {
      uint32_t ticks = 0x8000000;
      PRINTF( "." );
      while (ticks--)
      {
        __asm("nop");
      }
    }
    EwPrint( "\r\n" );
  }
}
 

 

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...