I am using several array variables. The last variable is always using a separate memory instead of using the consecutive memory right after the previous one. How do I make them in continuously memory?
Why do you (think you) want to do this? What is your goal here ?
The 'C' programming language gives you no guarantees about memory layout - unless you use a struct ...
Even within a struct, the compiler may add "padding" to give optimum data alignment ...
The variable blocks have to be stored into flash memory so that when power is off and on again, program can retrieve them to RAM. If they locate at different RAM areas, then I can't use a single loop to move them to RAM when power is restores.
A struct would be the usual way to go for this.
As an added bonus, 'C' does allow you co just assign one struct to another - so you don't even have to write any loop or memcpy.
Indeed, collect related items, variables, arrays, etc into a STRUCTURE or UNION
The linker also provides for means of describing areas/sections of memory into which specific variables can be directed.
But for pulling data too/from EEPROM, FLASH, or a File a struct is the way to go.
Much better than a random assortment of globals with no order or associativity.
Thanks for the solution. Will find time to test if "struct" may solve my problem.
View all questions in Keil forum