Memory unit
Memory is part of the microcontroller whose function is to store data. The easiest way to explain it is to describe it as one big closet with lots of drawers. If we suppose that we marked the drawers in such a way that they can not be confused, any of their contents will then be easily accessible. It is enough to know the designation of the drawer and so its contents will be known to us for sure.
Memory components are exactly like that. For a certain input we get the contents of a certain
addressed memory location and that's all. Two new concepts are brought to us: addressing and
memory location. Memory consists of all memory locations, and addressing is nothing but
selecting one of them. This means that we need to select the desired memory location on one
hand, and on the other hand we need to wait for the contents of that location. Beside reading
from a memory location, memory must also provide for writing onto it. This is done by
supplying an additional line called control line. We will designate this line as R/W (read/write).
Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then
writing is done on the memory location. Memory is the first element, and we need a few
operation of our microcontroller .
Central Processing Unit
Let add 3 more memory locations to a specific block that will have a built in capability to
multiply, divide, subtract, and move its contents from one memory location onto another. The
part we just added in is called "central processing unit" (CPU). Its memory locations are called
registers.
Registers are therefore memory locations whose role is to help with performing various
mathematical operations or any other operations with data wherever data can be found. Look at
the current situation. We have two independent entities (memory and CPU) which are
interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for
example, we wish to add the contents of two memory locations and return the result again back
to memory, we would need a connection between memory and CPU. Simply stated, we must
have some "way" through data goes from one block to another.
Bus
That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires
There are two types of buses: address and data bus. The first one consists of as many lines as
the amount of memory we wish to address, and the other one is as wide as data, in our case 8
bits or the connection line. First one serves to transmit address from CPU memory, and the
second to connect all blocks inside the microcontroller. As far as functionality, the situation has improved, but a new problem has also appeared: we
have a unit that's capable of working by itself, but which does not have any contact with the
outside world, or with us! In order to remove this deficiency, let's add a block which contains
several memory locations whose one end is connected to the data bus, and the other has
connection with the output lines on the microcontroller which can be seen as pins on the
electronic component.
Input-output unit
Those locations we've just added are called "ports". There are several types of ports : input,
output or bidiectional ports. When working with ports, first of all it is necessary to choose which
port we need to work with, and then to send data to, or take it from the port.
Serial communication
Beside stated above we've added to the already existing unit the possibility of communication
with an outside world. However, this way of communicating has its drawbacks. One of the basic
drawbacks is the number of lines which need to be used in order to transfer data. What if it is
being transferred to a distance of several kilometers? The number of lines times number of
kilometers doesn't promise the economy of the project. It leaves us having to reduce the
number of lines in such a way that we don't lessen its functionality. Suppose we are working
with three lines only, and that one line is used for sending data, other for receiving, and the
third one is used as a reference line for both the input and the output side. In order for this to
work, we need to set the rules of exchange of data. These rules are called protocol. Protocol is
therefore defined in advance so there wouldn't be any misunderstanding between the sides that
are communicating with each other. For example, if one man is speaking in French, and the
other in English, it is highly unlikely that they will quickly and effectively understand each other.
Let's suppose we have the following protocol. The logical unit "1" is set up on the transmitting
line until transfer begins. Once the transfer starts, we lower the transmission line to logical "0"
for a period of time (which we will designate as T), so the receiving side will know that it is
receiving data, and so it will activate its mechanism for reception. Let's go back now to the
transmission side and start putting logic zeros and ones onto the transmitter line in the order
from a bit of the lowest value to a bit of the highest value. Let each bit stay on line for a time
period which is equal to T, and in the end, or after the 8th bit, let us bring the logical unit "1"
back on the line which will mark the end of the transmission of one data. The protocol we've
just described is called in professional literature NRZ (Non-Return to Zero).
As we have separate lines for receiving and sending, it is possible to receive and send data
(info.) at the same time. So called full-duplex mode block which enables this way of
communication is called a serial communication block. Unlike the parallel transmission, data
moves here bit by bit, or in a series of bits what defines the term serial communication comes
from. After the reception of data we need to read it from the receiving location and store it in
memory as opposed to sending where the process is reversed. Data goes from memory through
the bus to the sending location, and then to the receiving unit according to the protocol.
Timer unit
Since we have the serial communication explained, we can receive, send and process data.
However, in order to utilize it in industry we need a few additionally blocks. One of those is the
timer block which is significant to us because it can give us information about time, duration,
protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose
numeric value increments by one in even intervals, so that by taking its value during periods T1
and T2 and on the basis of their difference we can determine how much time has elapsed. This
is a very important part of the microcontroller whose understnding requires most of our time.
Watchdog
One more thing is requiring our attention is a flawless functioning of the microcontroller
during its run-time. Suppose that as a result of some interference (which often does occur in
industry) our microcontroller stops executing the program, or worse, it starts working
incorrectly.
Of course, when this happens with a computer, we simply reset it and it will keep working.
However, there is no reset button we can push on the microcontroller and thus solve our
problem. To overcome this obstacle, we need to introduce one more block called watchdog. This
block is in fact another free-run counter where our program needs to write a zero in every time
it executes correctly. In case that program gets "stuck", zero will not be written in, and counter
alone will reset the microcontroller upon achieving its maximum value. This will result in
executing the program again, and correctly this time around. That is an important element of
every program to be reliable without man's supervision.
Analog to Digital Converter
As the peripheral signals usually are substantially different from the ones that microcontroller
can understand (zero and one), they have to be converted into a pattern which can be
comprehended by a microcontroller. This task is performed by a block for analog to digital
conversion or by an ADC. This block is responsible for converting an information about some
analog value to a binary number and for follow it through to a CPU block so that CPU block can
further process it.
Finnaly, the microcontroller is now completed, and all we need to do now is to assemble it into
an electronic component where it will access inner blocks through the outside pins. The picture
below shows what a microcontroller looks like inside.
Physical configuration of the interior of a microcontroller
Thin lines which lead from the center towards the sides of the microcontroller represent wires
connecting inner blocks with the pins on the housing of the microcontroller so called bonding
lines. Chart on the following page represents the center section of a microcontroller.
For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need
a program that would be executed, and a few more elements which make up a interface logic
towards the elements of regulation (which will be discussed in later chapters).
No comments:
Post a Comment