This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Declaring memory space in external memory

Hi,

I'm using the STM32F103ZD microcontroller. This uC is residing on some control board and is physically connected by it's address bus and data bus to an external 1M*16 SRAM memory chip.

I would like to declare a static buffer (which is larger than the onboard uC ram memory) in this external memory. Lets assume the external memory access starts at address 0x8000 0000.

My questions is: is it possible to declare such a static 'external' buffer in the source code, and if so, how should I declare this buffer?

Thanks in advance,

Henk

Parents
  • "static" as in hiding it from global namespace?
    Or "static" as in a "global" variable hidden inside a function?
    Or you mean something else with "static"?

    You can specify an absolute address for the variable.
    Or you can specify that the object file should have the data placed in a specific memory region and specify in the scatter file that the region should use this address range.
    Or you can just define multiple address regions in the project file, and let the linker store as much as fits in the internal RAM and then place the remaining global variables in the external memory region.

    Note that your startup file must have correctly configured the SDRAM controller before you jump into the C startup code, if you want the startup code to be able to correctly zero-initialize or assign initial values to variables stored in the SDRAM region.

Reply
  • "static" as in hiding it from global namespace?
    Or "static" as in a "global" variable hidden inside a function?
    Or you mean something else with "static"?

    You can specify an absolute address for the variable.
    Or you can specify that the object file should have the data placed in a specific memory region and specify in the scatter file that the region should use this address range.
    Or you can just define multiple address regions in the project file, and let the linker store as much as fits in the internal RAM and then place the remaining global variables in the external memory region.

    Note that your startup file must have correctly configured the SDRAM controller before you jump into the C startup code, if you want the startup code to be able to correctly zero-initialize or assign initial values to variables stored in the SDRAM region.

Children
  • Per refers to SDRAM, but this also means setting up the external bus (FSMC) to which you SRAM is attached, part of the typical startup.s code with CMSIS is to call SystemInit() prior to __main(). You can do the bus setup in the SystemInit code.

    If you are going to floor-plan the memory manually you could use
    unsigned char *extbuf = (unsigned char *)0x80000000;

    Though I'd think it more likely to be 0x60000000, or 0x64000000