lpcware

hard fault when FreeRTOS heap is in external SDRAM

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Alex on Thu Nov 06 03:16:37 MST 2014
Hi

I'm running a LPC1778 with a 16Mbit external SDRAM. The LPC runs at 120MHz and the SDRAM at 60MHz.
The application uses FreeRTOS and lwip.
I made a stripped down version that fits completly in the internal RAM to check if it is an SDRAM issue or a general software problem.
When I place the FreeRTOS heap in external RAM I get a hard fault while initializing lwip. It seems that a ponter is corrupted.
When I place the FreeRTOS heap in internal RAM the application runs without problems.

I already did a test with a reduced clock frequency of 32 MHz but the result is the same.

The SDRAM is tested on every startup using this test:

<code>
for(int j = 0; j < 3; ++j)
  {
    unsigned int* adr = (unsigned int*) 0xA0000000;
    for(unsigned int i = 0; i < (256 * 1024); ++i)
      *adr++ = (i << 18) | i;

    adr = (unsigned int*) 0xA0000000;
    for(unsigned int i = 0; i < (256 * 1024); ++i)
    {
      unsigned int tmp = *adr++;
      if(tmp != ((i << 18) | i))
        goto SD_RAM_ERROR;
    }
    adr = (unsigned int*) 0xA0000000;
    for(unsigned int i = 0; i < (256 * 1024); ++i)
      *adr++ = 0xA5A5A5A5;
    adr = (unsigned int*) 0xA0000000;
    for(unsigned int i = 0; i < (256 * 1024); ++i)
    {
      unsigned int tmp = *adr++;
      if(tmp != 0xA5A5A5A5)
        goto SD_RAM_ERROR;
    }
  }

  unsigned int* adr = (unsigned int*) 0xA0000000;
  for(int i = 0; i < 32; ++i)
  {
    *adr = 1 << i;
    if(*adr != 1 << i)
      goto SD_RAM_ERROR;
  }
</code>

The test runs without any problems.
The FreeRTOS heap size is 35 kB and placed at address 0xA0000000.

Is there something to consider when placing something in external SDRAM? Read/Write timing or memory alignment?

Regards,
Alex

Outcomes