Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.
 
  • Like
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.
 
  • Like
Reactions: shaiko

    shaiko

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

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top