Basics about microcontrollers

Thread Starter

vinothmct

Joined Sep 24, 2012
14
I'm new to embedded field . I wish to know how the codes are stored in the memory. I been reading mazidi book about embedded . I have a few doubts . Stack is internal section of RAM . What exactly does stack do? Flash is RAM or ROM?

RAM is a volatile memory which loses its contents when power is switched off
ROM is non volatile . Our codes are stored here and constants are stored here ..

Take a LED a led on off program?

What are the functions of RAM and Flash?
Is flash a RAM or ROM

Flash is program memory which executes our program right?
Where is the C code we have written stored RAM or Flash?
What exactly does stack do here.
Lets say We write a delay function? Is it stored in Flash or RAM.

Can someone explain me the flow . Been keen to know this . Searched around counldn't find ..
 

t06afre

Joined May 11, 2009
5,934
You could take a look here http://en.wikipedia.org/wiki/Flash_memory
In Microcontrollers flash memory is used to store the program code. So for simplicety think about it as ROM. You write the code into it once during chip programming. And after that it stays unchanged. Your delay routine will go into the flash ROM like the rest of the code. In micros RAM is used to tempoarely store values used by the program (stored in ROM). You can picture you ROM as a printed book. And RAM as witheboard.
The stack is something more complex. Take a look at the wiki paper about it http://en.wikipedia.org/wiki/Stack_(abstract_data_type)
 

MrChips

Joined Oct 2, 2009
30,712
C->ASM->binary->Flash

A program written in C is compiled to assembly code which is then assembled into binary code. The binary object code can be stored in either RAM or ROM.

FLASH is a type or erasable/reprogrammable ROM. For embedded systems, the binary code is usually stored in FLASH (but not always. It can also be stored in a serial ROM and then loaded into RAM for execution.)

A stack uses part of RAM. This is a place to store temporary values, inter-program parameters, and return addresses.

In a complex multitasking environment, the stack can be used to store entire programs, disk swaps and dynamic memory allocations.
 
Top