Variables stored in RAM

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
While debugging a uC code - I noticed that all variables declared outside of the "main" function are stored in the RAM.

Why does this happen?
Is this always true?
 

Yes, variables declared outside main function are global variables and they are created in RAM and always exist.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
While debugging a uC code - I noticed that all variables declared outside of the "main" function are stored in the RAM.
..
Aren't all the variables supposed to be stored in RAM? :?:

They are global variables and stored in memory stack (RAM).
Local (auto) variables, usualy are stored in stack (RAM).
There are some exceptions for mC that do not implement stack control, but always variables are stored in RAM. Only constant values can be stored in ROM.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…