10120 - What is a micrcontroller

2011.06.30

What is a microcontroller ?

If you ask a student what is a microcontroller, he may answer “It contains a CPU, memories and I/O units.” If you press for a different explanation, he may then say that it is low-cost, small, easy to use etc.

I would like to say that a microcontroller is a ‘stored-program, high-speed, low-voltage digital IC’. This description may make many people feel uneasy. So let me explain. We are not going to study the microcontroller as what it is made of. We are going to use the microcontroller. Hence it is more useful to know its characteristics which will affect its usage. Besides, such description leads to the following discussion.


IC

A microcontroller is an IC (integrated circuits), which means it is a small piece of electronic device. Usually an IC has to be mounted on a piece of PCB (printed circuit board) before it can be operated on. Some IC’s in dual-in-line packages can be inserted onto a wire-wrapping socket and connections can be made without making PCB’s. But the STM8S105 comes usually in LQFP (low profile quad flat package) and has to be soldered onto a piece of PCB, as seen on the kit. In fact its size is only 7mm by 7mm with a small distance of 0.5 mm between the centre lines of the adjacent pins. Fortunately, the pins are brought out onto pins at a pitch of 0.1-inch, suitable for wire wrapping.  
                       
                       

Digital

A microcontroller is an electronic digital device. Its operation involves logic states of ‘1’ and ‘0’ only. To avoid confusion, we shall restrict the word ‘set’ to imply ‘1’ or ‘high’ and the word ‘clear’ to imply ‘0’ or ‘low’. The word ‘reset’ then implies clearing an already set state and then set it again.
We will also consistently number the 8 bits of a byte as bits 7, 6, … to bit 0. Hexadecimal notations will be used, although the microcontroller actually works on 8 bits most of the time. It is good to be able to convert mentally any hexadecimal digit to a 4-bit combination (A=1010) and vice versa (0101=5).
Thus, 0x53 will bring to mind almost instantly the binary number 01010011.
It is also important to note the range of an 8-bit number to be 0 to 255 if unsigned, and -128 to 127 if signed. Usually unsigned numbers are used, as signed numbers are hard to deal with. An unsigned 16-bit number has a maximum value of 65535.                                                                                         

Low voltage

Perhaps this should not be included in the description. But the transition from the classical 5-V system to the 3.3-V system is long overdue. This development will only discuss 3.3-V system. It will touch on the 5-V supply only when necessary, for example in using an older 5-V alphanumeric dot matrix LCD.


High Speed

A microcontroller usually runs with a clock signal in the MHz (megaHertz) range. Higher speed is usually not required. Even at frequency of 1 MHz, one cycle has a period of 1 us (microsecond) which is very fast for a human being. Thus, in many cases, the microcontroller has to be programmed to wait a while for the user to see the changing LED’s or to hear the beep sound. For such purposes, software delays are usually used in the early stage. At the later stage, timer interrupts may be introduced to enable events to occur at regular intervals. Beginners should get used to talking in terms of us (microseconds) and ms (milliseconds).


Stored-Program

The operation of a microcontroller is controlled by a program stored in its memory. In the past, a program is usually stored in another EPROM chip outside the microcontroller (then termed microprocessor), using an EPROM programmer. Subsequently, the program memory is placed inside the microcontroller. This then required special equipment to place the program into the chip. Lately, simpler devices (programmers) are used to download the program from a computer to the microcontroller. The process is usually called boot-loading. Such simpler devices differ in technique and price. They may also provide debugging capability. Recently, these programmers/debuggers have become rather low cost, which makes it much easier for the hobbyists. By the way, the size of the on-chip program memory is usually large that we seldom talk about efficient usage of the program memory.