cancel
Showing results for 
Search instead for 
Did you mean: 

SDRAM speed on STM32429I-EVAL

marko2399
Associate
Posted on September 08, 2015 at 10:10

Hello everyone

I did some basic and low level SDRAM tests on the STM32429I-EVAL and got some weird results or at least I think they are strange. I'm using the IAR Embedded Workbench and the including toolchain. Optimizations are set to ''high'' and focus is on ''speed''. This is the shape of my test:

  // Write pattern to buffer, word by word

  printf(''BEGIN - word by word\n\r'');

  int patternInt = 0xCCCCCCCC;

  count = COUNT;

  printf(''writing %dMB to ram...\n\r'',

         COUNT * allocatedMemory / 1024 / 1024);

  gettimeofday(&lasttv, NULL);

  while (count > 0) {

    for (int i = 0; i < allocatedMemory / 4; i++)

      memoryBufferInt[i] = patternInt;

    --count;

  }

  gettimeofday(&tv, NULL);

  timeDiff = tvDiff(&tv, &lasttv);

  printf(''time used to write %dMB to ram: %d.%ds\n\r'',

         COUNT * allocatedMemory / 1024 / 1024, timeDiff.tv_sec, timeDiff.tv_msec);

  printf(''writing speed: %dMB/s\n\r'',

         COUNT * allocatedMemory / 1024 / 1024 / timeDiff.tv_sec);

  // Read from buffer, word by word

  int readInt;

  count = COUNT;

  printf(''reading %dMB from ram...\n\r'',

         COUNT * allocatedMemory / 1024 / 1024);

  gettimeofday(&lasttv, NULL);

  while (count > 0) {

    for (int i = 0; i < allocatedMemory / 4; i++)

      //HAL_SDRAM_Read_32b(hsdram, (uint32_t*)(SDRAM_ADDRESS + 4*i) ,&readInt, 1);

      readInt = memoryBufferInt[i];

    --count;

  }

  gettimeofday(&tv, NULL);

  // this if statement has been moved from the read loop and is needed here, so the compiler doesn't optimize the variable readInt

  if (readInt != patternInt)

    printf(''read error at position %d\n\r'', 0);

  timeDiff = tvDiff(&tv, &lasttv);

  printf(''time used to read %dMB from ram: %d.%ds\n\r'',

         COUNT * allocatedMemory / 1024 / 1024, timeDiff.tv_sec, timeDiff.tv_msec);

  printf(''reading speed: %dMB/s\n\r'',

         COUNT * allocatedMemory / 1024 / 1024 / timeDiff.tv_sec);

  printf(''END - word by word\n\r'');

I basically merged the two examples FMC_SDRAM and UART_Printf and changed the SDRAM init code according to another project I'm working on. The original SDRAM settings show the same/similar results. These are the speed results:

BEGIN - word by word

writing 160MB to ram...

time used to write 160MB to ram: 5.909s

writing speed: 32MB/s

reading 160MB from ram...

time used to read 160MB from ram: 8.650s

reading speed: 20MB/s

END - word by word

As you can see the speed of writing and reading is pretty low and I expected the reading speed to be faster than writing. I will try to attach the source files, last time I did this, my post disappeared. Thank you very much for your help.

Greetings

mg

#sdram
1 REPLY 1
Posted on September 08, 2015 at 14:44

The write buffer allows the write to get differed, the reads have to complete in the execution path.

The SDRAM is not particularly fast, and not cached. Executing code from SDRAM is about 6x slower than SRAM, as I recall.

Display buffer and blitter access might be faster as the synchronicity can be exploited.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..