PYE 422 Lecture Note
PYE 422 Lecture Note
Microprocessor
A microprocessor is a data processor. It is designed to be able to process
large quantities of complex data at high speed. A micrometer usually
operates more slowly and has less processing capability.
Actuator
Actuator is a device in a control system which performs an action. e.g.
motors, solenoids.
Interface
Interface is a circuit used for passing information between two other circuits
.e.g. a modem.
System clock
System clock is the square wave generator which provides the regular
series of pulses which drive the CPU.
Busses
Busses are the sets of parallel conductors which aid the rapid transfer of
data between the CPU and the other parts of the system.
Types of Busses
There are three types are: Data bus
Address bus
Control bus
Control unit
This is a highly complex logic circuit which finds out what the
microprocessor must do next and oversees the doing of it. There are
several stages in its operations and it steps from stage to stage in response
to pulses arriving from the system clock.
Internal bus
This has similar structure ad performs similar functions to the address and
data busses of the external microelectric system. i.e. It aids rapid transfer
of data within the cell.
Counters
Program counter- It is a register which holds the most recently accessed
address.
Stack pointer- It is a register which is used to hold the address of the top of
the stack. The stack is a small block of memory where very important data
is stored temporarily.
Registers
Status register- It is a register which holds essential information about the
result of an operation that has just occurred.
Instruction register- It is the register in which an instruction code read from
the memory is placed.
Accumulator- This is a special register which is set aside as the main
register used in processing.
Choice of a CPU
The important points of consideration when choosing a CPU for any
microelectronic system are:
i. Microprocessor or microcontroller
ii. Clock speed
iii. Bus width
iv. Instruction width
v. ILO facilities
vi. On-chip facilities
Microprocessor or microcontroller
If the system is required to process a large amount of data very quickly, a
microprocessor should be chosen. If high performance and complex data
processing is not essential, then a microcontroller is chosen.
Clock speed
High speed is essential for large-scale processing especially real-time
control and complex graphics.
Bus width
The wider the address bus, the larger address space. The wider the data
bus, the easier and faster it is to process large numerical values more
precisely.
Instruction width
The choice between a CISC processor and a RISC processor depends
partly on the application, In general, RISC processors are considered to be
the faster choice.
ILO facilities
The number of ILO pins or ports are different for different microprocessors
and microcontrollers.
On-chip facilities
The amount of RAM, ROM, EPROM/EEPROM differ for various CPUs.
RAM
RAM is used for temporary storage. Data may be written into it at any time,
and later read from it. The data is lost when the power supply is switched
off. It is used for the storage of data and for programs copied from more
permanent data stores such as magnetic disks. There are two types: Static
RAM (SRAM) and Dynamic RAM (DRAM).
EPROM
This is Erasable Programmable ROM. The ROM consists of an array of
MOSFETs, one for each bit. During programming, a charge is pulsed on to
the gates of those MOSFETs that are to be set to ‘1’. EPROMs have a
quartz window through which the chip can be exposed to ultraviolet light if
the data is to be erased.
EEPROM
This is Electrically Erasable Programmable ROM, which can be
programmed and reprogrammed while still connected in its circuits.
Although it can be used for temporary storage just like a RAM, writing new
data into EEPROM is too slow for this to be practicable.
Bit
A bit is a digit of a binary number. It can be either ‘O’ (low) or ‘I’(high).
Nibble
A nibble is a binary value consisting of 4bits.
Byte
A byte is a binary value consisting of 8 bits.
Word
A word is a double byte of 16 bits.
System Clock
A system clock is essential because processors need to be clocked to
operate very rapidly so as to process as much data as possible in a given
time.
CISC
CISC processors operates with a large number of different instructions, out
of which a relatively small number (20%) of the instructions are used for the
majority (80%) of the operations in practice. While RISC processors use
reduced instruction set of fewer than a hundred instructions.
RISC
RISC processors as a result of the reduced instruction sets are faster than
the CISC processors.
Machine code
Machine code is a set of codes which indicate the states of electronic
storage devices (flip-flops, MOSFET transistors or fusible links) in a
microelectronic system. They exist as a set of high and low voltages. High
voltage means ‘I’ while low voltage means ‘O’.
Assembler program
An assembler program is a software that makes it possible to write the
source code in other forms and have it automatically turned into machine
code.
The advantages of assembler program over machine code are:
Easily remembered mnemonics are used
It can use decimal numbers
It has comments
Automatic assembly
Error reporting
Labels for addresses, registers and variables
ASCII
ASCII is the American Standard Code for Information Interchange and is
the standard way of coding letters, numerals and punctuation and also a
number of printer-control commands. It is an 8-bit binary code with a range
of values from 0 to 255.
Examples:
The first 32 values are the control characters. Particularly code 32 is
a space.
Codes 48 to 57 are the numerals 0 to 9.
Capital letters of the alphabet begin at code 65
Lower case letters begin at 97.
Codes in between 65 and 97 are used for punctuation.
Structural programming
Structural programming helps a program to:
Operate correctly
Operate efficiently
Be easily readable and understood by other people
Be easily readable and understood by the program writer a few
weeks or period of time later.
Be easily adapted and modified at a later date.
Programs representation.
Two ways of representing programs are:
(i) Flowcharts
(ii) Design structure diagrams DSDs.
Program Structures
The three basic program structures:
Sequences: This is a series of processes taking place one after the
other. Some programs consist of a single sequence and run straight
through, from ‘Start’ to ‘End’.
Iteration: The program has a loop. The loop may continue indefinitely,
or until some condition is true.
Selection: There is a choice between alternative paths, depending on
whether a condition is true or not. In some programs, only one path
leads to specific action. In other programs each path leads to an
appropriate action.
Program Design
The various stages in program design are:
Initialization- It is concerned with defining variables, their types, and
possibly their initial values, definition of constants, labelling of
addresses of ports and data direction registers etc.
Input- It may be broken down into smaller sections especially if a
certain sequence of ley-presses has to be made.
Processing- This stage may be anything from a simple sequence of
one or two program lines, to a complex combination of sequences,
iterations and selections.
Output- This is often a simple sequence, because all the work of
processing has been done and it remains only to light an LED or
switch on a motor.
Subroutine
Subroutine is useful when a particular sequence of operations has to be
repeated at several different points in a program. It saves much time and
memory space.
Stack
The stack is a region of RAM set aside for the temporary storage of data. It
works in a ‘last-in-first-out’ (LIFO) manner. The stack pointer in the CPU
holds the address of the address next above the top of the stack. The stack
is often used for temporarily storing an intermediate result in a calculation.
It is also used for registering the state of the processor when a jump to
subroutine is expected, or when the microprocessor is responding to an
interrupt.
Generation of Interrupt
The different circumstances in which an interrupt may be generated are:
Arithmetic error: A good example is ‘division by zero’. This is detected
inside the CPU and causes it to interrupt itself. Instead of going on to
the next instruction in the program, it jumps to a special Interrupt
Service Routine (ISR).
Exception error: Occasionally a CPU may be given instructions that it
is impossible to obey, such as storing a batch of data in an area of
memory that does not exist. Hence, an internal interrupt occurs.
Clocked interrupts: If a system includes a real-time clock, it can be
programmed to interrupt the processor at regular intervals.