Sie sind auf Seite 1von 2

30. 04. 2018.

Computers, Microprocessors, Microcomputers, Microcontrollers

Computers, Microprocessors, Microcomputers,


Microcontrollers
OCTOBER 20, 2007 BY DECETH 0 COMMENTS

NOTE: This course gives specific information and examples for the Freescale HCS12 Microcontroller.

The below image represents a computer system based on the von Neumann architecture. The HCS12 microcontroller is a von Neumann architecture machine.

[2]

The term microprocessor first came into use at Intel in 1972 and generally refers to the implementation of the central processor unit functions of a computer in a single, large
scale integrated circuit. A microcomputer is a computer built using a microprocessor and a few other components for the memory and I/O.

A microcontroller is a microcomputer with its memory and I/O integrated into a single chip. In 2004, the industry delivered 6.8 billion microcontroller units. [1]

Important Notation: [1]

$ Hexadecimal numbers are denoted by a leading $: For example, $FFFF is the hexadecimal number FFFF. When two memory locations are to be identified, the starting and
ending adresses are given as $FFFE:FFFF.

% Binary numbers are denoted by a leading %: for example, $F may be written as %1111.

@ A base-8 octal number is preceded by @: for example $F = @17

# A # indicates immediate addressing mode.

x An x indicates a don’t care bit. x could be either 0 or 1.

A computer is not some sort of mystical creature that is beyond comprehension. It is a human made device composed of basic digital logical components that anybody could design.

A typical microcontroller consists of the following elements: [1]

A central processor unit (CPU) that contains registers, an arithmetic and logic unit (ALU), and a sequence controller to control all activities of the microcontroller.
Read only memory (ROM) to hold a program and any constant data. Modern microcontrollers have reprogrammable types of read only memory such as flash memory, which is a
particular type of electrically erasable programmable read only memory (EEPROM).
Random access memory (RAM) to store variable data.
An input/output (I/O) interface to connect the micrcontroller to the real world. The I/O interface in most microcontrollers contains other useful functions such as timers, pulse-width
modulators, and other special I/O functions.

When a program is written in a high-level language like C or C++ it must then be converted to bytes representing the operation that must be done and the operands that are being
operated upon. There is a unique code for each operation to be executed by the microcontroller. For example:

CF 0A 00

The above is an example of instruction code bytes. All addresses and instruction code bytes are in hexadecimal format which will then be translated to binary format.

In the above example, the instruction code bytes correspond to the following in Assembly code: LDS #$0A00. CF is the opcode byte for LDS and the following two bytes 0A 00 are the
bytes for the operands.

A computer instruction is the combination of an operation (what the computer is to do) and zero, one, or more operands (what the computer is going to do it to). Again, given the above
example, the instruction tells the microcontroller to load or initialize the stack pointer register with the value $0A00.

The central processing unit (CPU) contains registers. There are accumulator registers and registers used to access memory.

Accumulators A and B: The two 8-bit accumulators, A and B, may be a source or destination operand for 8-bit instructions. for example, if we were to retrieve a byte of data from
memory we may put it in accumulator A or B. The registers are called accumulators because the results of an arithmetic or logic operation may accumulate there.

Program Counter (PC): Although the program counter is usually shown in the programmer’s model, the programmer does not have direct control over it like the other registers. The
number of bits in the program counter shows how much memory can be directly addressed.

Index Register: The program may use an index register to access memory. As we will see when we find out more about the HCS12 microcontroller, there are a variety of instructions
that access memory using this type of register.

The Instruction Execution Cycle [1]

The process by which the microcontroller executes each instruction in a program is called the instruction cycle. When an instruction opcode is to be fetched from ROM, the memory must
be supplied with the address of the opcode and the read control signal asserted. This is how the instruction cycle starts and it continues by fetching the rest of the instruction bytes, doing
whatever is required by the instruction, incrementing the program counter to point to the next opcode, and then repeats.

The CPU’s program counter contains the address of the first byte of the instruction to be executed. We say the program counter points to the opcode. The CPU places that address
on the address bus.
The sequence controller asserts the Read control signal on the control bus.
After a small delay, called the memory access time, the ROM places the contents of the addressed memory location on the data bus.
The sequence controller writes this byte into the instruction decoder.
The instruction decoder holds the opcode byte and decodes it for the sequence controller.

http://software-engineer-training.com/computers-microprocessors-microcomputers-microcontrollers/ 1/2
30. 04. 2018. Computers, Microprocessors, Microcomputers, Microcontrollers
The decoded instruction causes the sequence controller to go through a sequence of actions that complete the execution on the instruction. These include fetching operands from
memory, loading registers, performing an arithmetic or logical operation on a pair of operands, and incrementing the program counter.
When the instruction execution is complete, the program counter is pointing to the next opcode to be fetched and executed. The instruction execution cycle then repeats.

The instruction execution cycle continues forever, or at least until the power is turned off or a special instruction that stops it is encountered.

[2]

Sequence Controller [1]

The sequence controller generates control signals required by the currently executing instruction, at the correct time, to accomplish the information transfer operation. The sequence
controller is designed to allow different instructions to be executed in different amounts of time. For example, take an 8-bit immediate addressing instruction that transfers a byte from the
memory immediately following the opcode byte to some register in the CPU. In the freescale HCS12 instruction set this could be the instruction that loads accumulator A with the data
$22.

ldaa #$22

At the start of the instruction execution cycle, the program counter is pointing at the opcode, and the execution cycle starts by fetching the opcode. Next the program counter will be
incremented, the byte will be transferred from memory to the register and the program counter will be incremented again to point to the next opcode. This process will then repeat as the
execution cycle will start be fetching the next opcode, etc…

Arithmetic and Logic Unit (ALU)

The ALU contains the digital logic to operate on operands in the way specified by the opcode. It does arithmetic, logic and other operations such as shifts, rotates, increments,
and decrements. The ALU receives inputs from the accumulator registers and the data bus and places its outputs to accumulator registers and the data bus. [1]

[2]

[1] Fredrick M. Cady, Software and Hardware Engineering: Assembly and C Programming for the Freescale HCS12 Microcontroller
[2] Prof. Gilbert Arbez, University of Ottawa CSI3531 Course Notes, Module 1

http://software-engineer-training.com/computers-microprocessors-microcomputers-microcontrollers/ 2/2

Das könnte Ihnen auch gefallen