Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Variables stored in RAM

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,641
Helped
302
Reputation
606
Reaction score
297
Trophy points
1,363
Activity points
18,256
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?
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
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

xenos

Full Member level 4
Joined
May 9, 2015
Messages
212
Helped
82
Reputation
164
Reaction score
81
Trophy points
28
Location
127.0.0.1
Activity points
1,182
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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top