Skip to main content
Scott Gravenhorst
Senior
March 16, 2018
Solved

STM32F746G-Discovery SDRAM Curious Behavior

  • March 16, 2018
  • 9 replies
  • 1483 views
Posted on March 16, 2018 at 19:50

I'm writing a crude memory diagnostic for SDRAM (just to see if I can). The code accesses SDRAM using a pointer.

__IO uint32_t * SDRAM_ptr;

SDRAM_ptr = (__IO uint32_t *)0xC0000000;

Using this pointer in a loop, I can write and read the first 2 megabytes reliably, but more than 2 megabytes causes the program to hang (sits and does nothing after the SDRAM read starts). I assumed that the program would fail beyond 0xC0800000, but its failing when beyond 0xC0200000.

The LCD display is not enabled.

CPU clock is set to 200 MHz.

Initialization was done with HAL and BSP functions.

Another curious behavior is that if I set the diagnostic to test 2 megabytes (0x00200000), I can set SDRAM_ptr to any of 0xC0000000, 0xC0000004 and 0xC0000008 as a starting point and the diagnostic works meaning that at least 8 bytes beyond 0xC0200000 seem to be accessible. If I set to 0xC0000010, it fails. The program writes data values starting at 0x00000000 and incrementing by 4 for each uint32_t location. Yet if I set the length of SDRAM to test to 0x00200004, it fails.

Any clues about what I'm doing wrong?

Note: this post was migrated and contained many threaded conversations, some content may be missing.
    This topic has been closed for replies.
    Best answer by Tesla DeLorean
    Posted on March 16, 2018 at 20:30

    The system will Hard Fault if you go beyond the geometry decoded by the FMC

    I tend to have the handler print out diagnostics so I know that it got there.

    The uint32_t point will advance 4 bytes at a time, 128-Mbit SDRAM (64 Mbits accessible), so 8MB, 0x200000 loop iterations at 32-bit

    9 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    March 16, 2018
    Posted on March 16, 2018 at 20:30

    The system will Hard Fault if you go beyond the geometry decoded by the FMC

    I tend to have the handler print out diagnostics so I know that it got there.

    The uint32_t point will advance 4 bytes at a time, 128-Mbit SDRAM (64 Mbits accessible), so 8MB, 0x200000 loop iterations at 32-bit

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Scott Gravenhorst
    Senior
    March 16, 2018
    Posted on March 16, 2018 at 20:45

    OH!  So the address used is pointing to 32 bit values, not 8 bit bytes.  0xC0000000 is the first 32 bit chunk and 0xC0000001 is the second.

    Thank you SO much, it is working now and I understand.

    Can't believe I didn't see that.  I know how that is supposed to work...  duh moment.

    Tesla DeLorean
    Guru
    March 16, 2018
    Posted on March 16, 2018 at 22:20

    Should advance 0xC0000000, 0xC0000004 as SDRAM_ptr++

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