cancel
Showing results for 
Search instead for 
Did you mean: 

FMC example address confusion

Manojkumar Subramaniam
Associate II

Hi, I've been wanting to understand the reason for WRITE_READ_ADDR offset address used in example codes,

below is the snippet, to give some idea what I am talking about.

so why 0x0800 ?

#define WRITE_READ_ADDR     ((uint32_t)0x0800)
 
 
  for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++)
  {
    *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex) = aTxBuffer[uwIndex];
  }
  

5 REPLIES 5
MM..1
Chief II

your example simply copy memory from aTxBuffer addr to external SDRAM at defined position. Then is write, but oposite function will read from same position...

Seems this is little complicated way , better is memcpy

And too i mean you can define variables to store in external ram and then compiler create locations and define not need. usw...

Just some random offset 2KB into the memory, perhaps a lower address was consumed by some other table/data. This is an example of manually floor-planning how to use memory.

Normally you'd let the linker allocate named variables/buffers, and use pointers in your C code. Or you'd malloc() from a dynamic memory pool in SDRAM, etc.

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

Where is this snippet from, what is it supposed to do?

If it is a real SDRAM and not a device with a memory-like parallel interface, and the buffer is not used for DMA transactions, there is no need for __IO (i.e. volatile). Of course it will still work, just prevents the optimizer creating efficient code.

No idea, but most FMC SDRAM example has the offset. I tried my best if that address were used for some other buffer, but looks like No!

Any best example to create the linker file to interface external RAM ?

I'm using the generic STM32CUBE ide provided toolchain