Concept 4 - ROM and RAM
Programming is also called coding and the code written is put into a space called ROM in the micro. ROM is Read Only Memory and cannot be changed after the code has been put into the micro, or code has been burned in.
Let's say we want the micro to add 4 and 5 and display the answer on a LCD display connected to the output pins.
We write the code say (4+5) compile it, get the machine code and dump it into the micro.
The code goes into the ROM of the micro, and when we switch on the micro, it resets, does (4+5) and displays the answer 9.
A smart guy would realise 4 + 5 will always be 9 and rewrite the code to just display 9!
So having a ROM, where we cannot change values is not such a good idea after all!
Would we not want to do 6+7 or 3+2 also?
That's why we have the input pins! And where do the inputs get stored?
In the RAM, or Random Access Memory. RAM contents can be changed any number of times and will remain in the memory of the micro as long as the micro is ON.
So are the answers in ROM or RAM? RAM, because they change with the inputs!
One of the important specifications, to look for in a micro is the size of the ROM and RAM. ROM generally varies from 4 Kbytes to 64 Kbytes, and RAM from 128 bytes to 2 Kbytes.
Just to refresh our memories, a byte has 8 bits and a Kbyte has 1000 or 1024 bytes?
Concept 4