We use the decimal system (base 10) to represent numbers, which uses ten digits, 0 to 9. Numbers can also be represented using a different base. The binary number system uses 2 as the base and the digits are 0 and 1 only. It is possible to represent them using switches having the two states, OPEN and CLOSED. In digital circuits, numbers are represented using a set of electronics switches.
It is also possible to perform arithmetic and logical operations using digital circuits like the AND, NOT and OR gates. For example, you can add two numbers using an adder circuit by feeding the inputs to it. However, for all practical purposes, we need to perform a series of such operations in an ordered manner. This was made possible by the concept of the ‘Stored Program’ introduced by John von Neumann in the late 1940s. This concept led to the modern digital computers. The arithmetic and logical operations are performed according to the bit patterns (called instructions) stored inside a series of memory locations. The timing of the operations are controlled by a clock signal.
A transistor switch is a one bit storage element and we can use a set of them to store a binary number. Such an arrangement is also called a Register. A large number of them can be organised as memory elements of different sizes. A Microprocessor consists of
The control circuit fetches Instruction from the external memory to the Registers, executes them using the ALU and stores the results back to the memory. The Registers are used as scratch pads for the temporary storage of data. Other than general purpose temporary storage there are some Registers with specific functions, as described below.
The Program Counter: The PC contains the memory location from which the instruction or data has to be brought or stored. It is incremented with every instruction and its contents are modified by Jump and Call instructions.
The Stack Pointer: This Register points to the memory location used as stack. A PUSH instruction stores the contents of some register to the memory location pointed to by the SP and increments the value of SP. A POP instruction retrieves the data and decrements SP.
The Status Register: The results of the ALU operations sets the various bits of this register, for example the CARRY bit if the result of an addition exceeded the register size.
The General Purpose Registers: In addition to the special registers mentioned above, there will be a set of general purpose registers. Some processors designate one of these registers as Accumulator, the default destination of the results of an ALU operation.
A microprocessor requires external memory for functioning. Instructions and data are fetched from this external memory and results stored to it. To be useful it should also have Input/output devices connected to it. Simple examples of I/O devices are switches and LEDs. More complex systems may have keyboards or graphical display units.
There are many types of memory devices that can be interfaced to a microprocessor. The storage devices like CDs, hard disks etc. are sequential type. Semiconductor memories are of Random Access type, means you can access any memory location by specifying the address of that memory location. This type is further classified into
The read/write memory is further classified into
The different types of non-volatile memory are
Integrating the memory and some peripheral devices to a microprocessor on a single chip results in a microcontroller. They are widely used in electronics instruments like calculators, telephone sets, copying machines, printers etc. A microcontroller has all the components of a microprocessor, like the ALU, control unit and the Registers. In addition to that it also has
The AVR series of microcontrollers are very popular and they are used in development systems like Arduino.
For a detailed description of AVR family of processors refer to this Wikipedia article.
The Registers and the Instruction set are explained HERE.
Several example programs in Assembler tested on AtMega32 are available HERE.