Electronic – RAM and stack memory

microchipmicrocontrollermicroprocessorpic

I'd like to know what is the difference between RAM ( data memory ) and the stack memory in PIC micro controllers if both of them is volatile( not sure about stack ) and the stack is temporary memory?

Best Answer

All RAM memory requires a constant current to hold its state. That is, as soon as you turn the power off, all of your RAM memory vanishes. Thus, RAM is volatile.

The stack is a specific area of RAM memory used to store temporary variables during program execution. Each function call "pushes" data to the stack. The data is "popped" when the function returns. Because the stack is stored in RAM, it too is volatile.