There is only 2K RAM in Atmega328. How much of the RAM is in heap and stack? If stack memory runs out, how can one allocate more RAM to stack instead of heap? If I do not use dynamic memory allocation, does it mean that the heap memory is useless and so, I should allocate most of the memory to stack? But how does one explicitly do the allocation?
lightaiyee: There is only 2K RAM in Atmega328. How much of the RAM is in heap and stack?
See memory layout here: http://www.nongnu.org/avr-libc/user-manual/malloc.html
There is no fixed size for stack and heap.
The stack starts at the end of the RAM adresses and grows down to lower addresses.
The heap starts behind your global variables at low addresses and grows to higher addresses.
In the middle of heap and stack there is the "free memory".
If stack and heap crash into each other because of RAM over-usage, your program will crash, too.