0

I use GNU for ARM and want to define some cell in RAM memory space as following:

#define FOO_LOCATION 0x20000000
#define foo (*((volatile uint32_t *) FOO_LOCATION ))

My question is - if such declaration will prohibit usage of the cell with FOO_LOCATION address in stack or heap? What address preffered to avoid memory fragmentation?


Update

I want to place some variable at a certain memory address and access it after watchdog reset. I guess that if i will declare it as usual

uint32_t foo;

it will have another physical location after reset. Also i read a post where said that most probably there is no such way to declare variable adddress. And i have idea to tell the GNU not to use some memory address. As for example special registers are not used by custom variables.


Update 2

In addition to previous definitions i added section to linker script

SECTIONS
{
  . = 0x20000000
  .fooSection :
  {
    *(.fooSection)
    . = 0x04 /* size = 4 bytes */
  } 
  /* other placements follow here... */
}
Community
  • 1
  • 1
  • That's not a declaration. That's just a macro, which is basically a fancy search/replace command in your source code. – melpomene Jul 31 '16 at 07:37
  • No, such declaration will not prohibit anything about stack or heap. Please clarify what you are trying to achieve. Please also clarify "What address preffered to avoid memory fragmentation" - I didn't understand that question. – anatolyg Jul 31 '16 at 08:01
  • thanks, i did an update to the topic @anatolyg – Vladimir Tsykunov Jul 31 '16 at 08:10
  • seems i found useful post which tells that the variable should be placed into a section https://mcuoneclipse.com/2012/11/01/defining-variables-at-absolute-addresses-with-gcc/ – Vladimir Tsykunov Jul 31 '16 at 08:33
  • 1
    It seems that you found the answer to your question. If yes, you might want to format it as an answer (though it might be too much trouble for you). If not, please specify what the question is. – anatolyg Jul 31 '16 at 09:31
  • Yes, seems i found the answer. Going to do some hardware tests. Thanks a lot. – Vladimir Tsykunov Jul 31 '16 at 12:37

0 Answers0